调用我自己的扩展jquery函数

时间:2013-12-29 21:25:54

标签: javascript jquery jquery-ui

我在这个链接中查看了这个例子,我遇到了一个问题: http://jqueryui.com/widget/

它以这种形式工作正常:

$(function() { ....});

但是如果我尝试在我用这种方式创建的文件中使用它:

var Manager = Class.extend({  // the same as prototype - I used class.js
    init: function () {},
    setupPage : function(options){
        $.widget('custom.colorize', {   //here I receive widget is unidentified
            shape: function () {        //just example
                this.x = 0;
                this.y = 0;
                this.w = 1;             //default width and height?
                this.h = 1;
                this.fill = '#444444';
            }
        });
    }
})

我该怎么做?

1 个答案:

答案 0 :(得分:0)

据我所知,在定义类时,jQuery UI lib尚未加载。您可以将Manager类定义放在

之间
$(function() { .... });

或者您可以重新排列脚本标记,以便在加载类创建脚本之前加载jQuery UI(我建议使用后者)。

相关问题