Actions of a controller called from the aftermodel method can modify the template?


#1

Im triying to show a specific bootstrap tap, when refresh the browser, if the records of my model doesn’t meet a condition.

In the aftermodel i determinate what tab must show, and i called a action from the controller to show the tab with jquery, but looks like the template has not been loaded.

The aftermodel is:

afterModel: function(pendingTrader) {

var countPending = 0;
var countConfirmed = 0;
var firtsConfirmed = null;
for(var i = 0; i < pendingTrader.get('length'); i++){

    if(!pendingTrader.objectAt(i).get('isConfirmed')){
        countPending++;
        this.controllerFor('portfolio').send('updateDefaultPerformance', pendingTrader.objectAt(i));
        break;
    }else{
        countConfirmed++;
        if(countConfirmed === 1){
           firtsConfirmed = pendingTrader.objectAt(i);
        }
    }
}

if((countPending === 0) && (countConfirmed > 0)){
    this.controllerFor('portfolio').send('updateDefaultPerformance', firtsConfirmed);     
}

}

And the controller action:

updateDefaultPerformance: function(pTrader){

this.send('setPerformance', pTrader);
if(pTrader.get('isConfirmed')){
    console.log("Set default a followedActive");
    $('a[href=#followed]').tab('show');  // this doest'n work
}else{
    console.log("Set default a pendingActive");
}

}

whats happening? how i can execute the action when the template is really loaded?


#2

Finally I solved my problem, to execute actions after loading the template and calculated properties has been resolved , it is enough to overwrite the didInsertMethod of view associated with the template must be loaded.