(编辑:jimmy 日期: 2024/11/16 浏览:2)
本文实例讲述了jQuery 图片查看器插件 Viewer.js用法。分享给大家供大家参考,具体如下:
html:
<!-- 引入文件 --> <link rel="stylesheet" href="/css/viewer.min.css" rel="external nofollow" > <script src="/UploadFiles/2021-04-02/viewer.min.js">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扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery切换特效与技巧总结》、《jQuery遍历算法与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。