gpt4 book ai didi

javascript - this._mouseInit() 不是函数

转载 作者:行者123 更新时间:2023-11-29 20:21:16 25 4
gpt4 key购买 nike

我刚刚将我的代码更新到 jqueryui 1.8,它给了我这个错误:this._mouseInit 不是函数。我将如何解决这个问题?我有一个小部件可以让鼠标开始拖动和停止。这是我的代码:

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

}));

最佳答案

语法有点变化,你的开场白:

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

现在应该是:

​ $.widget("ui.boxTool", $.ui.mouse, {

确保更改最后一行以匹配,})); 现在应该只是 });

关于javascript - this._mouseInit() 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3902468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com