我构建 jQuery 插件:
(function( $ ){
var methods = {
init : function( options ) {
$.fn.queryBuilder = $.extend($.fn.queryBuilder, options);
return this.each(function(){
methods.getValues();
var $this = $(this),
data = $this.data('queryBuilder'),
url = '/'+methods.createURL.call();
if ( ! data ) {
$(this).data('queryBuilder', {
target : $this,
url : url
});
}
});
},
getURL:function(){
alert $(this);
}
}
$.fn.queryBuilder = function( method ) {
if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.tooltip' );
}
};
})
调用 getValues() 方法时,警报显示未定义。如何调用 getValues 与我的插件绑定的对象的范围?