javascript - Render a view in the outlet after ajax response -


in home page have oulet watchlistview want replace outlet view getting after clicking link "/watch_lists".

this code application layout/template

 <div id='main-outlet'>   {{outlet}}   <div class="watch-list-rght"><a href="/watch_lists"><i class="icon-eye-open"></i></a>  </div>  </div>  {{outlet watchlistview}} 

this code in application route

 this.resource('watchlist', { path: '/watch_lists' }); 

this code in watchlist router

 discourse.watchlistroute = discourse.route.extend({    redirect: function() { discourse.redirectifloginrequired(this); },    rendertemplate: function() {      this.render('watch_lists', { into: 'application', outlet: 'watchlistview' });    }   }); 

i want add view created after ajax call in application template

can point me out wrong.

your view loading outlet move route, has no data until populated ajax call. put logging in rendertemplate function , you'll see this.

i make ajax call in route's setupcontroller method, populating controller results of call can display results in view. see documentation on method more info.

in ajax callback, should populating controller results of call , have handlebars in template pointing data want display. load automatically when ajax call comes , populates controller:

setupcontroller:function(controller){     someobj.ajaxcall(function(data){         controller.set('data',data);     } } 

you can watch controller properties in watchlist template {{controller.data.property}} or {{{controller.data.htmlproperty}}} render html.

if not helpful enough, post jsfiddle illustrates you're doing.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -