i have a controller script in ember and iam using init() method in controller. this is my script
export default Ember.Controller.extend({
.....,
init() {
this._super(...arguments);
this.set('idUser', this.commonService.getUser().id);
Ember.$(document).ready(function () {
let height = Ember.$(window).height() - 96;
Ember.$(".feed-activity-list").slimScroll({
height: height.toString() + "px"
});
});
},
})
the init method is invoke when user first time open the page. but when user open another page and back to this page, the controller doesnt invoke the init() method. how to force the controller run init method when user visit this page. Iam avoid using component because its hard to refactor :(
Controller is singleton so only one time
initwill be called. You can make use of the corresponding routeactivatehook ordidTransitionhook. but its not guaranteed by that time DOM is ready. you might need to useEmber.run.nextorEmber.run.later('afterRender', () => { }).Use
componentthat is the ember best practise.