我刚刚将代码更新为jqueryui 1.8,它给了我这个错误:
this._mouseInit is not a function
。我该如何解决这个问题?我有一个小部件,鼠标开始拖动和停止。这是我的代码:
$.widget("ui.boxTool", $.extend({}, $.ui.mouse, {
_create: function() {
this.element.addClass("ui-boxTool");
this.dragged = false;
this._mouseInit();
this.width = $('#toPinpoint').width();
this.height = $('#toPinpoint').height();
this.helper = $(document.createElement('div'))
.css({border:'1px dashed #c2c0c0'})
.css({cursor:'crosshair'})
.addClass("ui-boxTool-helper");
},
destroy: function() {
this.element
.removeClass("ui-boxTool ui-boxTool-disabled")
.removeData("boxTool")
.unbind(".selectable");
this._mouseDestroy();
return this;
},
_mouseStart: function(event) {
var self = this;
this.opos = [event.pageX, event.pageY];
if (this.options.disabled)
return;
var options = this.options;
this._trigger("start", event);
$(options.appendTo).append(this.helper);
this.helper.css({
"z-index": 100,
"position": "absolute",
"left": event.clientX,
"top": event.clientY,
"width": 0,
"height": 0
});
},
_mouseDrag: function(event) {
var self = this;
this.dragged = true;
...
return false;
},
_mouseStop: function(event) {
var self = this;
this.dragged = false;
var options = this.options;
var clone = this.helper.clone()
.removeClass('ui-boxTool-helper').appendTo(options.appendTo);
this._trigger("stop", event, { box: clone });
this.helper.remove();
//$('.view-mode').remove(this.helper);
return false;
}
}));
答案 0 :(得分:3)
语法改变了一点,你的开头行:
$.widget("ui.boxTool", $.extend({}, $.ui.mouse, {
现在应该是:
$.widget("ui.boxTool", $.ui.mouse, {
请务必更改最后一行以匹配,}));
现在应该只是});
。