how to trigger element features after render in ember-cli

半城伤御伤魂 提交于 2019-12-05 19:26:14

Try

enableToolTips: function() {
    Ember.run.scheduleOnce('afterRender', this, function() {
        var $el = Ember.$('.tip');

        console.log("TOOLTIP:", $el);
        if($el.length > 0) {
            $el.tooltip({
                html:true,
                delay: { show: 250, hide: 750 }
            });
        }
    });
}.observes('results')

Checking Ember.Component API there are two hooks that can do that

willClearRender : When component html is about to change.

willInsertElement : When old html is cleared and new one is going to be placed.

But you need to have a look on scheduleOnce.

Its worth noting that didInsertElement runs every time. But when it runs view was not updated. To solve that you need to run your code inside a Run Loop like this

didInsertElement : function(){
     var self = this;  
     Ember.run.scheduleOnce('afterRender', this, function(){

           //run tool tip here
           self.$().find(".tip").tooltip({

           });
     });

 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!