How to change this jQuery widget (written for jQueryUI 1.7) so that it works with jQueryUI 1.8

前端 未结 1 683
我寻月下人不归
我寻月下人不归 2020-12-18 15:09

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 upgra

相关标签:
1条回答
  • 2020-12-18 15:45

    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.

    0 讨论(0)
提交回复
热议问题