javascript - View binding undefined - Ember.js -


so have interesting issue. have sidebar, sortablestopview, extends collectionview have scrollable, sortable list of 'stops' user can click stop's summary page.

there sortablestopscontroller, arraycontroller used sort stops display_order. in hindsight, arraycontroller isn't necessary, don't believe issue here.

app.sortablestopcontroller = ember.arraycontroller.extend     sortproperties: ['display_order']     loaded: false     stopsmoved: false      observestuff: (->       console.log 'stops', @get 'content'       console.log 'loaded', @get 'loaded'     ).observes 'loaded', 'content' 

now, in stopsindexroute, have configcontroller. (all of routes extend app.authenticatedroute overrides setupcontroller, runs custom code, , calls configcontroller. it's used instead of setupcontroller throughout app.) here set content of sortablestopcontroller stops fetch via ember data , tell controller that data has been loaded.

app.stopsindexroute = app.authenticatedroute.extend     configcontroller: (controller, model) ->     self =      sortablestopctlr = @controllerfor 'sortablestop'      @store.find('stop', route_id: model.get("route_id")).then (stops) ->         sortablestopctlr.set 'model', stops         sortablestopctlr.set 'loaded', true 

this gets inserted stops.hbs (it needs on stops routes) with

{{view "sortablestop" content=controllers.sortablestop.arrangedcontent loadedbinding="controllers.sortablestop.loaded" movedbinding="controllers.sortablestop.stopsmoved"}} 

the issue following observer logs out this loaded undefined. same follows if log out content.

app.sortablestopview = ember.collectionview.extend     observeloaded: (->         console.log 'this loaded', @get 'loaded'     ).observes 'loaded' 

it's not shown here, stopscontroller, stopsindexcontroller, , stopseditcontroller has 'sortablestop' in needs array.

any thoughts?

if you're using recent version of ember, observers aren't firing until after controller set up. fix it, add on('init') observer:

observeloaded: (->   console.log 'this loaded', @get 'loaded' ).observes('loaded').on('init') 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -