Posted in jQuery onApril 04, 2020
本文实例讲述了jQuery 图片查看器插件 Viewer.js用法。分享给大家供大家参考,具体如下:
html:
<!-- 引入文件 --> <link rel="stylesheet" href="/css/viewer.min.css" rel="external nofollow" > <script src="/js/viewer.min.js"></script> <div id="viewPhotosDialog" title="查看图片" style="display: none"></div>
js:
html += " <img title='查看图片' onclick='viewPhotos(\"" + val.ot_id + "\")' src='/images/icon/info.jpg' style='cursor: pointer'></td>"; //查看图片 function viewPhotos(ot_id) { var Html = ""; $.ajax({ type: "post", async: false, dataType: "json", url: "/order/order/get-list", data: { ot_id: ot_id, type: 1 }, success: function (json) { if (json.ask) { Html += "<table border='0' class='myTab' width='100%'>"; Html += "<tr id='images'>"; if (json.data) { $.each(json.data, function (key, value) { Html += "<td><img style='width: 75px; height: 75px;' src='http://cff-img.oss-cn-shenzhen.aliyuncs.com/" + value + "'></td>"; }); } else { Html += "<td></td>"; } Html += "</tr></table>"; $("#viewPhotosDialog").dialog("open").html(Html); } else { alertTip(json.msg); } } }); var viewer = new Viewer(document.getElementById('images'), {url: 'data-original'}); } $(function () { $("#viewPhotosDialog").dialog({ title: "查看图片", autoOpen: false, modal: true, width: 1000, show: "slide", }); });
Controller:
class Order_OrderController extends Zend_Controller_Action { public function getListAction () { $type = $this->_request->getParam('type', 0); $otId = $this->_request->getParam('ot_id'); if ($type) { $otIds = Order_Service_Transport::getByOtId($otId); if ($otIds) { $images = explode(';', $otIds['images']); $data = array(); foreach ($images as $value) { $data[] = $value; } $return['ask'] = 1; $return['data'] = $data; } else { $return['ask'] = 0; $return['msg'] = '未获取到对应图片'; } die(json_encode($return)); } } }
希望本文所述对大家jQuery程序设计有所帮助。
jQuery 图片查看器插件 Viewer.js用法简单示例
- Author -
缤纷落叶之忠声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@