如何从嵌套 XUL 树中删除项目?
我使用 XUL 创建了一个嵌套树(没有使用数据库来存储项目)。我想通过选择项目(一次仅 1 个)然后单击“删除”来从该树中删除项目。我编写了 Javascript 函数来删除,如下所示,但它不起作用。
function delete(){
var tree = document.getElementById("treeId");
currentPos = tree.currentIndex;
var currentItem = tree.contentView.getItemAtIndex(currentPos);
var parent = currentItem.getParent();
parent.removeChild(currentItem);
}
我猜 getParent() 不是正确的方法,但没有找到任何其他方法。有人可以给我一些提示吗? 谢谢
I created a nested tree using XUL (no database was used to store items). I want to delete items from this tree by selecting the item (only 1 at a time) then click delete. I wrote Javascript function to delete as following but it does not work.
function delete(){
var tree = document.getElementById("treeId");
currentPos = tree.currentIndex;
var currentItem = tree.contentView.getItemAtIndex(currentPos);
var parent = currentItem.getParent();
parent.removeChild(currentItem);
}
I guess getParent() is not the right method but did not find any other method. Can someone give me some hints please.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了。这是我的错误。我刚刚意识到删除不能用作函数名称。
Problem solved. It was my mistake. I just realized that delete cannot be used as a name of function.