JQuery ui widget inheritance -


I need to customize the jquery UI widget. I just wanted to change the "create" method I've written a new widget inherited from ui.automplete widget. It works fine but how do I add new events like select, click, change? Is not it possible to add an event to widget inheritance?

  $ Widget ("ui.my_autocomplete", $ .ui.autocomplete, {_create: function () {// This is my custom code}, select: function (event, UI) {// not working! Console .log ("test my_autocomplete:"); ui.item.option.selected = true; .....}, change: function (event, UI) {// not working! Console.log ("- test my_autocomplete change:"); .....}}); JQuery UI 1.8:  
  $ Widget ("ui.autocomplete", {options} {minLength: 1, delay: 300}, _create: function () {...}, deleted: function () {...}, _setOption: function (key) { ...}, _initSource: function () {...}, search: function (value, event) {...}, _search: function (value) {...}, _response: function (content) {. ..}, close: function (event) {...}, _normalize: function (item) {...}, _suggest: function (item) {...}, _renderMenu: function (ul, item) {. ..}, _renderItem: function (ul, item) {...}, _move: function (direction, event) {...}, widget: function () {...}});  

Yes it is possible, but if you want events, I think that You are doing it wrong ... At present, you are adding them as methods such as:

  $ ('selector'). Widget ('select');   

If you want regular events, you can add them directly to the element by doing this in your _create method:

  _create: function () { // Force normal events. Element Click (function () {...}); This.element.select (function () {...}); // How a custom event this._trigger fire ('myEvent', incident, data); });   

If you want to supply a callback for a custom event example, you can do this by supplying the init options, or you can bind it:

  $ ('selector'). Bind ('myWidgetmyEvent', function (event, UI) {...});    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -