jquery ui 中的外掛程式開發

來源:互聯網
上載者:User

標籤:

1  $.widget()      

必須引用

 <script src="@Url.Content("~/Scripts/jquery-ui-latest.js?v="+ViewBag.vv+"1")" type="text/javascript"></script>


2.

(function ($) {    $.widget("hw.CamScan", {        options: {          //外掛程式的參數        },        ///create the widget 根據配置顯示對應的ui        _create: function () {            var self = this;                      //這裡初始化資訊        },           _hasNoControl: function (idPrefix) {//外掛程式中定義的內部方法                },                       ScanUpload: function (Value, fileName) {//外掛程式中定義的外部方法           },              destroy: function () {            this.element.empty();            $.Widget.prototype.destroy.apply(this, arguments);        }    });})(jQuery);


3  如何使用  

            $("#sa").CamScan({                scanurl: "http://localhost:56630/",                scanaction: "testplub/ScanUpload",                userid: "99999",                CAMurl: "http://localhost:56630/",                CAMaction: "testplub/CamUpload"            });


4如何調用外掛程式中的方法

$("#sa").CamScan("ScanUpload", "params", "filename")

其中 params  filename  對應上面  ScanUpload 中的 value 和 filename

5 如何擷取到外掛程式中事件

    外掛程式中使用 trigger

jQuery("#" + id).trigger(‘ScanUploadscuess‘, fileName + ".jpg 上傳成功!");         //成功觸發一個事件

   頁面載入時使用 bind

  $("#sa").bind("CamSMsuccess", function (e, value) { alert(value); });

6  trigger多個參數  (與外掛程式無關)

  

jQuery("#" + id).trigger(‘jsimg‘, [image, saomiaoid]);         //成功觸發一個事件


  調用方法

 $("#@ViewBag.tabcid" + "_scancontrol").bind("jsimg", function (e, img,id) {其中 img id 即為 傳出的參數}

  通過 jquery trigger 和 bind 方法我們可以擷取到 外掛程式中定義的事件

 

jquery ui 中的外掛程式開發

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.