O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Switching contexts

As previously discussed, Ember.js resolves expressions against the model context. The {{#with}}...{{/with}} helper allows us to specify the context to prioritize during the check. A good case is illustrated in the chapter sample, where we need to reuse the form used to create or update contacts. This form is contained in the contacts/form template. The only problem is that while the context of the contacts/new template is a newly created contact object, the contact/edit template has to reference the contact proxied by the contact controller. Thanks to the with helper and controller dependencies, we are able to change the context of the latter template as:

<script type="text/x-handlebars" data-template- name="contact/edit"> {{#with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required