如何从嵌套 XUL 树中删除项目?

发布于 2024-09-24 17:14:39 字数 444 浏览 0 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2024-10-01 17:14:39

问题解决了。这是我的错误。我刚刚意识到删除不能用作函数名称。

Problem solved. It was my mistake. I just realized that delete cannot be used as a name of function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文