Javascript Ember.js-路由

Javascript Ember.js-路由,javascript,ember.js,ember-router,Javascript,Ember.js,Ember Router,我有这样的问题:需要创建一个日期选择器,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.re

我有这样的问题:需要创建一个日期选择器,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')};
  } 
});

如何创建更改年/月/日以及包含它们的位置和处理逻辑的按钮?

我们最终使用此解决方案在我们的ember.js应用程序中选择日期:

它需要一些样式更新,但除此之外,很容易实现