javascript - Ember.js action bubbles up and skips a route -


setup

imagine ember.js app (tried v1.13.9) structure:

  1. applicationroute
  2. indexroute
  3. indexcontroller

on index template, there's button action:

<!-- index/template.js --> <button {{action 'ping' 'index template'}}>index</button> 

all routes/controllers handle action, printing out message , passing action until reaches applicationroute. eg, indexroute is:

// excerpt index/route.js actions: {   ping(from) {     console.log('indexroute^ping from', from);     return true;   } } 

this same action can originate @ indexcontroller:

// excerpt index/controller.js thingshappen() {   this.send('ping', 'index controller'); } 

you can see code , play @ these urls:

question

when press button, messages show action seen 3 routes/controllers, in order, inside bubbling up. however, when action sent indexcontroller, skips indexroute. why this?

it's related fact route hasn't been transitioned yet. index route isn't part of current chain. if want make sure index route has been loaded can hook transition promise , wait complete before calling action.

 setupcontroller(controller, model, transition) {     controller.wake('non attached');     transition.then(function(){       controller.wake('attached');     });   }, 

http://ember-twiddle.com/e36c0228967fb4485d27


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -