jQuery 图片查看器插件 Viewer.js用法简单示例

jQuery 图片查看器插件 Viewer.js用法简单示例

html:

<!-- 引入文件 --> <link href="https://www.jb51.net/css/viewer.min.css" > <script src="https://www.jb51.net/js/viewer.min.js"></script> <div title="查看图片"></div>

js:

html += "&nbsp;&nbsp;&nbsp;&nbsp;<img title='查看图片' src='https://www.jb51.net/images/icon/info.jpg'></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>"; Html += "<tr>"; if (json.data) { $.each(json.data, function (key, value) { Html += "<td><img 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 图片查看器插件 Viewer.js用法简单示例

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery切换特效与技巧总结》、《jQuery遍历算法与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/509b1d92ecc14ae00299e40b717ef6c3.html