This jQuery plugin, which lets users draw rectangles in a div, works with jQueryUI 1.7.2.
I need to get it working with jQueryUI 1.8.4. From reading the widget upgrade guide, I can't work out what needs to change. I tried renaming _init() to _create(), but that didn't do anything. What else do I need to change to get it working? Thanks for reading.
The $.widget signature changed to do the extend internally, so change this:
$.widget("ui.boxer", $.extend({}, $.ui.mouse, {
To this:
$.widget("ui.boxer", $.ui.mouse, {
And at the bottom, remove the extra ) as well, changing })); to });
Also, to get the default options, it's best to move them right inside, like this:
$.widget("ui.boxer", $.ui.mouse, {
options: {
appendTo: 'body',
distance: 0
},
///rest of widget, unchanged...
});
Here's a sample of the updated version with only the changes above, working.
来源:https://stackoverflow.com/questions/4310189/how-to-change-this-jquery-widget-written-for-jqueryui-1-7-so-that-it-works-wit