2013-08-29 6 views
-1

J'ai un tel problème: besoin de créer un sélecteur de date, avec l'url "/ année/xxxx/mois/yy/jour/zz, où xxxx, yy et zz seraient l'année, mois et jour de la date sélectionnée.Ember.js - Routing

Ce code est pour générer url de la page d'index:

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')}; 
    } 
}); 

Comment créer un des boutons qui changent année/mois/jour et où les contiennent et poignée logique?

Répondre