ember js subviews和didinsertelement事件 [英] ember js subviews and didinsertelement event
问题描述
我正在写一个 Ember.View
,它将一个树结构变成一个菜单。我需要递归,所以我在我的视图模板中使用的是一个 {{view}}
帮助程序,它递归地调用自己来构建一个嵌套的 < ul>< li>
结构。
I'm writing an Ember.View
, which turns a tree structure into a menu. I need recursion for this, so what I use in my view template is a {{view}}
helper, which recursively calls itself to build a nested <ul><li>
structure.
我需要的是一个钩子来调用一些jQuery插件将此结构转换为菜单。当我从 didInsertElement
事件调用插件时,子视图尚未呈现。所有子视图完成渲染后,如何运行代码?
What I need is a hook to call some jQuery plugin to turn this structure into the menu. When I call the plugin from the didInsertElement
event, the subviews haven't rendered yet. How can I run code when all subviews have finished rendering?
推荐答案
尝试调用Ember.run.next()中的插件应该在当前的运行循环完成之后调用它...我相信在创建所有子视图之前不会发生。
Try calling the plugin within Ember.run.next() which should call it after the current run loop is complete... which I believe won't happen until all of the subviews are created.
文档 - > http://docs.emberjs.com/symbols/Ember.run.html
这篇关于ember js subviews和didinsertelement事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!