[英]Ember.js dynamic links
I'm trying to develop a webapp involving race results of my local running group. 我正在尝试开发一个Web应用程序,该应用程序涉及我当地跑步团体的比赛结果。 Ember.js looked like a nice framework to develop the website.
Ember.js看起来是一个不错的网站开发框架。
My code at this very moment: 此刻我的代码:
App.Router.map(function() {
this.resource('results', function(){
this.resource('year');
});
});
App.ResultsRoute=Ember.Route.extend({
model: function() {
return $.getJSON("../api/api.php?method=years");
//returns a JSON array with all the years a certain race went through => [{"year":"2008"},{"year":"2009"},{"year":"2010"}]
},
});
App.YearRoute=Ember.Route.extend({
model: function(params){
//some horrible code
}
});
On the left side of my website all the years appear in a list. 在我的网站的左侧,所有年份都显示在列表中。 When I click on a year, the race results appear on the right side.
当我单击年份时,比赛结果将显示在右侧。
How do I adjust the Router.map so the url looks like "www.example.com/index.html#/results/2008" when I click on the year 2008? 单击2008年时,如何调整Router.map,使网址看起来像“ www.example.com/index.html#/results/2008”?
As a noob programmer, I have a difficult time figuring this out. 作为一个菜鸟程序员,我很难解决这个问题。
App.Router.map(function() {
this.resource('results', function(){
this.resource('year', {path:'/:year'});
});
});
Here's an example 这是一个例子
http://emberjs.jsbin.com/oMAYUzIq/1/edit http://emberjs.jsbin.com/oMAYUzIq/1/edit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.