我使用jQuery和jQueryUI获得以下HTML:
<script type="text/javascript">
$(document).ready(function () {
$('#myGrid').widgetGrid();
});
</script>
然后我有以下Jquery小部件代码(Javascript):
(function ($) {
$.widget("mzui.widgetGrid", {
options: {
},
_init: function () {
this.value = 1;
this.redraw();
},
redraw: function () {
that = this;
this.element.empty();
this.div = $("<div></div>");
this.element.append(this.div);
this.text = $("<p>Value = " + this.value.toString() + "</p>");
this.div.append(this.text);
this.input = $("<input type='number' onchange='that.onInputChange(value)' min='1' max='100' value='1'/></span>");
this.div.append(this.input);
},
onInputChange: function (value) {
this.value = value;
this.redraw();
},
_destroy: function () {
this.element.empty();
}
});
}(jQuery));
一切运行正常,但每次我输入新号码时,我都会在浏览器控制台上收到以下错误:
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is no longer a child of this node. Perhaps it was moved in a 'blur' event handler?
此错误发生在redraw()
函数内部,根本不会影响屏幕元素。
我需要帮助来了解什么类型的错误是什么以及如何解决它。
提前致谢。