如何更改此 jQuery 小部件(为 jQueryUI 1.7 编写)使其与 jQueryUI 1.8 一起使用 [英] How to change this jQuery widget (written for jQueryUI 1.7) so that it works with jQueryUI 1.8

查看:24
本文介绍了如何更改此 jQuery 小部件(为 jQueryUI 1.7 编写)使其与 jQueryUI 1.8 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个 jQuery 插件,允许用户在 div 中绘制矩形,适用于 jQueryUI 1.7.2.

This jQuery plugin, which lets users draw rectangles in a div, works with jQueryUI 1.7.2.

我需要让它与 jQueryUI 1.8.4 一起使用.通过阅读 小部件升级指南,我无法确定需要更改的内容.我尝试将 _init() 重命名为 _create(),但这并没有做任何事情.我还需要更改什么才能使其正常工作?感谢阅读.

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.

推荐答案

$.widget 签名更改为在内部进行扩展,因此更改此:

The $.widget signature changed to do the extend internally, so change this:

$.widget("ui.boxer", $.extend({}, $.ui.mouse, {

到这里:

$.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.

这篇关于如何更改此 jQuery 小部件(为 jQueryUI 1.7 编写)使其与 jQueryUI 1.8 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆