灰烬重渲染组件 [英] Ember re render component
本文介绍了灰烬重渲染组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有可转换DOM的jquery菜单的组件。我需要重新渲染组件以再次启动结构。 jQuery菜单无法彻底解决问题,因此我需要重新渲染组件。
I have a component with a jquery menu that transforms the DOM. I need to re render the component for initiate the structure again. The jquery menu doesn't work dinamically, so I need to re render the component.
//Parent Component hbs
<div id="container">
{{menu-jquery model=model}}
</div>
//Parent Component js
export default Ember.Component.extend({
refreshMenuData(){
callToServer()// ajax call
updateModel()// generate model from ajax response
-> //how to delete and create menu component? or re render menu component?
}
}
谢谢
推荐答案
我找到了一种解决方法,将组件放入条件块中。在服务器调用之前将装入设置为false,在数据解析之后将装入设置为true。
I found a workaround putting the component inside a conditional block. I set loading in false before the server call and true after data parsing.
{{#if loading}}
// show loading message
{{else}}
{{menu-jquery model=model}}
{{/if}}
这将强制菜单组件重新呈现。
This force the menu component to re render.
这篇关于灰烬重渲染组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文