我有这样的问题:需要创建一个日期选择器,url为“/year/xxxx/month/yy/day/zz,其中xxxx、yy和zz是所选日期的年月日。
此代码用于生成索引页面的 url:
App.Router.map(function () {
this.resource('years', {path: '/'},function(){
this.resource("year", { path: "/year/:year_id" }, function() {
this.resource("month",{path:"/month/:month_id"},function(){
this.resource("day",{path:"/day/:day_id"});
});
});
});
});
App.YearsRoute = Ember.Route.extend({
redirect: function(param)
{
var rec =App.Model.createRecord({
year:2013,
month:8,
day:28,
id:1
});
this.transitionTo('year',rec);
}
});
App.YearRoute = Ember.Route.extend({
redirect:function(param){
this.transitionTo('month',param);
},
serialize:function(param){
return {year_id: param.get('year')};
}
});
App.MonthRoute = Ember.Route.extend({
redirect:function(param)
{
this.transitionTo('day',param);
},
serialize:function(param){
return {month_id:param.get('month')};
}
});
App.DayRoute = Ember.Route.extend({
serialize:function(param){
return {day_id:param.get('day')};
}
});
如何创建一个更改年/月/日的按钮以及包含它们和句柄逻辑的按钮?