我試圖DOM重新渲染DOM中的組件的HTML當我打電話this.rerender();
在下面的例子中,我有一個數據保存到服務器的形式,並完成後我想重置表單以便用戶可以提交更多數據。我不想單獨清除每個屬性(這只是一個例子,除了表單外還有其他用途)。目前,當我運行this.rerender();
,它調用的方法,如didRender()
但不替代DOM中的HTML。重新渲染組件在Ember.js
有沒有人有一個線索如何做到這一點?
實施例:
route.hbs
{{my-component}}
MY-component.js
actions: {
submit: {
// save form data to server, etc.
this.rerender(); // re-render html in DOM
}
}
MY-component.hbs
<form {{action 'submit' on='submit'>
{{input id='name' value=name}}
<button class="btn green" type="submit">Login</button>
</form>
我確實有把所有的表單數據到像用戶數據對象的想法,但我是有清除它的問題。我認爲我的問題的根源在於我使用Materialize將組件放入模式中,並且導致組件在某些情況下出現奇怪現象。儘管如此,謝謝你的回答! –