Short version of this question: I'm trying to re-render my ApplicationView when a specific event (language change) occurs. ApplicationView only contains a simple outlet, however, when re-rendering, this outlet remains empty. So what is the right approach for reprocessing an entire page?
Simplified application code (http://jsfiddle.net/6ZQh7/2/):
Ember.Handlebars.registerHelper('t', function() { return App.get('language') == 'en' ? 'Hi there!' : 'Hallo!'; }); App = Ember.Application.create({ language: 'en', ApplicationView: Em.View.extend({ templateName: 'application' }), TestView: Em.View.extend({ templateName: 'test' }), ApplicationController: Em.Controller.extend(), Router: Em.Router.extend({ root: Em.Route.extend({ toggleLanguage: function(router) { App.set('language', App.get('language') == 'en' ? 'nl' : 'en');
Relevant HTML:
<script type="text/x-handlebars" data-template-name="application"> <h1>{{t whatever}}</h1> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="test"> <h2>My Test Page</h2> <a href="#" {{action toggleLanguage}}>Toggle language.</a> </script>
By doing some debugging (well, some, a few hours), it seems that when you re-render the ContainerView, which displays the output, has no context, which means there is no currentView (which is attached to this context), which means nothing is displayed in the socket. Scratch what a working context is; if I call this.get('templateData.keywords.view.context') in ContainerView # init with a debugger, I get a controller application. Interestingly, however, this.get('templateData.keywords.view.context.view') (which should return the view to exit) returns undefined, whereas `this.get ('templateData.keywords.view.context'). Get ('view') returns the image.
Context: I'm trying to write an internationalized Ember.js application that contains a simple translation helper that prints strings in the current language (shared with Ember-I18n). Currently changing the language requires reloading the page, because these language strings are not connected (and I would justly say that, since changing the language is rare and creating bindings for each line on the page sounds like a bad idea). However, I would like to simply re-render instead of rebooting.