Mar 26
jQuery UI is latest news at jQuery world. Current release supports 5 widgets (Accordion, Datepicker, Dialog, Slider, Tabs). jQuery give provision to create our own widget as per our need. Basic syntax to create our own widget
$.widget("ui.mywidget", {
_init: function() {
// init code for mywidget
// can use this.options
if (this.options.hidden) {
// and this.element
this.element.hide();
}
},
_doSomething: function() {
// internal functions should be named begin with an underscore
// manipulate the widget
},
value: function() {
// calculate some value and return it return
this._calculate();
},
length: function() {
return this._someOtherValue();
}
,
destroy: function() {
$.widget.prototype.apply(this, arguments); // default destroy
// now do other stuff particular to this widget
}
});
$.extend($.ui.mywidget, {
getter: "value length",
defaults: { option1: "defaultValue", hidden: true }
});










Recent Comments