javascript - Ember how do I know when a route template is finished loading and fire a callback? -
currently working on chat app ember, going fantastic ember nice work with.
i have chat window, many lines of people chatting.
i scroll chat window down on initial page load, here's example:
<div class="chat-window"> {{ chat-message username="john doe" message="blah" dispic="unknownuser.jpg" }} </div>
so how might bind event entire template being loaded (in case index.hbs
i know can components through like:
import ember 'ember'; export default ember.component.extend({ didinsertelement() { this.$('.button-collapse').sidenav(); } });
which works fine, equivalent doing template.
as far know there index.hbs
, index.js
route file.
any information great thanks.
send action component route. route retrieve data server , after data retrieved route update data.
route can handle loading state. (from guide)
the code that:
import ember 'ember'; export default ember.route.extend({ chatdata:[], model:function(){ return this.get('chatdata'); }, actions:{ loading:function(){ //do loading... }, chatdatarequested:function(){ retrievedata().then((datafromserver)=>{this.set('chatdata',datafromserver);}); } } });
Comments
Post a Comment