Ember.js: Design pattern for communicating to view from model -


what's design pattern accessing model's view model?

i have item ds.model, itemcontroller, itemscontroller, , itemview, linked standard render in template iterates on itemscontroller's content:

items.hbs:

{{#each item in content}}    render 'item' item {{/each}} 

i have newitem event on itemscontroller, creates new item object , prepends controller's content array:

items_controller:

app.itemscontroller = ember.arraycontroller.extend   actions:     newitem: ->       newitem = @get('store').createrecord 'item'       @get('content').insertat(0, item, 0) 

this works fine: after next run loop, new itemcontroller + itemview created , changes reflected in dom automatically.

however, want set mouse focus on element inside newly inserted itemview (call function focusme), seems reduces how can access (or send events to) model's view model? know in general information flows one-way model -> controller -> view in ember, how else accomplish this?

thoughts:

  1. didinsertelement won't work, because want call focusme items created via newitem action, , don't want couple every view.
  2. it seems logical place inside newitem action definition itself, newitem.getview().focusme(), of course requires access model's view.
  3. i looked @ get references emberjs views created given model object?, think adding observer every single itemview overkill, when newly created items via newitem action need focused.
  4. also, tried solution, , couldn't work (that answer on year old).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -