Plug-in development in the jquery UI

Source: Internet
Author: User

1 $.widget ()

Must reference

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


2.

(function ($) {$.widget ("HW. Camscan", {options: {//plug -In Parameters        },        ///Create the widget to display the corresponding UI according to the configuration_create:function () {varSelf = This; //here to initialize the information}, _hasnocontrol:function (idprefix) {//internal methods defined in the plug- in}, Scanupload:function (Value, fileName) {//external methods defined in the plug- in}, Destroy:function () { This. Element.empty (); $. Widget.prototype.destroy.apply ( This, arguments); }    });}) (jQuery);


3 How to use

$("#sa"). Camscan ({scanurl:"http://localhost:56630/", Scanaction:"Testplub/scanupload", UserID:"99999", Camurl:"http://localhost:56630/", Camaction:"Testplub/camupload"            });


4 How to invoke a method in a plug-in

$ ("#sa"). Camscan ("scanupload" "params " " FileName")

where params filename corresponds to value and filename in the above scanupload

5 How to get to events in plugins

Using Trigger in plugins

JQuery ("#" + ID). Trigger ('scanuploadscuess'). JPG Upload Successful! ");         // successfully triggering an event

Use bind when page loads

  $ ("#sa"). Bind ("camsmsuccess", function (E, Value) {alert (value);});

6 trigger multiple parameters (independent of plug-ins)

  

JQuery ("#" + ID). Trigger ('jsimg', [image, Saomiaoid]);         // successfully triggering an event


Calling methods

$ ("# @ViewBag. Tabcid""_scancontrol"). Bind (  "jsimg", Function (e, img,id) {where the IMG ID is the outgoing parameter}

With the jquery trigger and bind methods we can get the events defined in the plugin

Plug-in development in the jquery UI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.