How to extend a jquery ui widget ? (1.7)
- by Jide
I would like to create a custom version of the sortable widget. I have been searching for documentation, but could not find something really accurate. The best information I found was : http://jqueryui.pbworks.com/Widget-factory.
I tried :
$.widget("ui.customsortable", $.extend($.ui.sortable, {
_init: function() {
$.widget.prototype._init.apply(this, arguments);
}
}));
But $.widget.prototype._init is not the function I want to call I guess since it is the $.widget prototype.
Then, I tried something I read here and there :
var _init = $.ui.sortable.prototype._init;
$.widget("ui.customsortable", $.extend($.ui.sortable, {
_init: function() {
_init.apply(this, arguments);
},
}));
But :
I can't believe I have to store all methods I want to override like this, it is so ugly.
It throws an error ("this.refresh is not a function"), which means the refresh method does not exist. Does that mean I would have to recreate all methods I want to override ? What's the point of extending in that case ?
Am I missing something here ?
Thanks for your help !