【问题标题】:AddChild to a parent's element (from iframe)AddChild 到父元素(来自 iframe)
【发布时间】:2015-03-29 05:01:33
【问题描述】:

我想给这样的元素添加一个子元素:

myLayout.root.contentItems[ 0 ].addChild( newItemConfig );

但是来自一个孩子(意思是来自一个 iframe):

parent.myLayout.root.contentItems[ 0 ].addChild( newItemConfig );

当我调用“addChild”时,我得到一个未定义的函数。我该怎么做?

顺便说一句,我正在尝试从 iframe 执行此操作(https://golden-layout.com/examples/#cdcb9de8e7b305d2ec81b4ae4e392832,查看 JS 代码)

PS 我的 webapp 使用 angularjs

【问题讨论】:

  • iframe 的 URL 是否与父级不同?
  • 数组 parent.myLayout.root.contentItems 不是空的吗?如果不是,它有什么(对象类型)?
  • @GrzegorzKaczan no...它有很多东西(对象、字符串等...)
  • @Rliger 相同的 URL 但似乎问题是因为我从 iframe 调用...

标签: javascript angularjs addchild


【解决方案1】:

也许你应该使用 appendChild()?

【讨论】:

    猜你喜欢
    • 2014-04-08
    • 1970-01-01
    • 2011-12-07
    • 2013-02-25
    • 1970-01-01
    • 1970-01-01
    • 2015-10-05
    • 1970-01-01
    • 2013-04-22
    相关资源
    最近更新 更多