I have an ember route that I've stripped down to
App.MyRoute = Ember.Route.extend({
model: function(params){
console.log("model function executing");
Ember.Object.create()
},
setupController: function(controller){
console.log("setupController function executed");
}
});
When I switch to MyRoute, the setupController gets executed, but the function to populate the model never does. The model ends up just being the msg
object that was passed in the {{link myRoute msg}}
tag.
There are parts of the model that I need to load/compute at the time that we switch to that route. To do this I need to either be able to successfully update the model, or I need access to the params passed in the link from within the setupController function. Suggestions on how best to achieve this?
EDIT
To try to hash this out, I've created a complete minimal example that will produce this behavior:
my html is:
<html>
<head>
<title> This is my Page! </title>
<script src="js/libs/jquery-1.8.2.js"></script>
<script src="js/libs/handlebars-1.0.rc.1.js"></script>
<script src="js/libs/ember.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<script type="text/x-handlebars">
{{#linkTo example App.thing}}<p> go </p>{{/linkTo}}
<div>
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="index">
<p> Initial Text </p>
</script>
<script type="text/x-handlebars" data-template-name="example">
<p> After change </p>
</script>
</body>
</html>
with the app code:
var App = Ember.Application.create();
App.Router.map(function() {
this.resource("example", {path: "/example/:id"});
});
App.thing = Ember.Object.create({
id:10,
});
App.ExampleRoute = Ember.Route.extend({
model: function(params){
console.log("in model function");
return new Ember.Object.create();
},
setupController: function(controller){
console.log("in setupController");
}
});
When you click on the link to the example route, "in setupController" prints, but "in model function" does not.