1
我尝试使用下面的代码来重命名节点:对象不支持属性或方法“孩子”重命名当节点JStree
'rename': function (t)
{
$("#demo").jstree("rename");
}
错误:微软JScript运行时错误:对象不支持属性或方法“孩子”
我试图degug和我收到上述错误在jquery.jstree.js的下面的代码文件
**Error @ line [w1 = obj.children("ins").width(),]**
_fn : {
_show_input : function (obj, callback) {
obj = this._get_node(obj);
var rtl = this._get_settings().core.rtl,
w = this._get_settings().crrm.input_width_limit,
w1 = obj.children("ins").width(),
w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length,
t = this.get_text(obj),
h1 = $("<div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"),
h2 = obj.css("position","relative").append(
$("<input />", {
"value" : t,
"class" : "jstree-rename-input",
// "size" : t.length,
"css" : {
"padding" : "0",
"border" : "1px solid silver",
"position" : "absolute",
"left" : (rtl ? "auto" : (w1 + w2 + 4) + "px"),
"right" : (rtl ? (w1 + w2 + 4) + "px" : "auto"),
"top" : "0px",
"height" : (this.data.core.li_height - 2) + "px",
"lineHeight" : (this.data.core.li_height - 2) + "px",
"width" : "150px" // will be set a bit further down
},
"blur" : $.proxy(function() {
var i = obj.children(".jstree-rename-input"),
v = i.val();
if(v === "") { v = t; }
h1.remove();
i.remove(); // rollback purposes
this.set_text(obj,t); // rollback purposes
this.rename_node(obj, v);
callback.call(this, obj, v, t);
obj.css("position","");
}, this),
"keyup" : function (event) {
var key = event.keyCode || event.which;
if(key == 27) { this.value = t; this.blur(); return; }
else if(key == 13) { this.blur(); return; }
else {
h2.width(Math.min(h1.text("pW" + this.value).width(),w));
}
},
"keypress" : function(event) {
var key = event.keyCode || event.which;
if(key == 13) { return false; }
}
})
).children(".jstree-rename-input");
this.set_text(obj, "");
h1.css({
fontFamily : h2.css('fontFamily') || '',
fontSize : h2.css('fontSize') || '',
fontWeight : h2.css('fontWeight') || '',
fontStyle : h2.css('fontStyle') || '',
fontStretch : h2.css('fontStretch') || '',
fontVariant : h2.css('fontVariant') || '',
letterSpacing : h2.css('letterSpacing') || '',
wordSpacing : h2.css('wordSpacing') || ''
});
h2.width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
},
请帮助...谢谢。
你可以在违规行中放置一个断点,并检查'obj'到达该点时的值吗?请注意,该错误可能不会在第一次到达该行时发生。 – lanzz
@lanzz obj的值为false,obj.children在行中未定义:w1 = obj.children(“ins”)。width(), – Anuya
您在其他浏览器中获得的结果是否相同,或者是否与IE相关? – lanzz