,我尝试过操纵路线,我让他们工作,但我只是想知道为什么当没有其他路线重新加载时,主页的链接实际上会重新加载页面。骨干家庭路线在一个非常简单的主干应用中重新加载页面
这里是我的路由器:
App.Router = Backbone.Router.extend({
routes: {
'': 'index',
'trips': 'trips',
'trips/new': 'newTrip',
'trips/:id': 'showTrip'
},
index: function(){
App.trips = new App.Collections.Trips ;
App.trips.fetch().then(function(){
new App.Views.App({ collection: App.trips });
});
},
trips: function(){
console.log('All trips') ;
},
newTrip: function(){
console.log('new trip') ;
var new_trip = new App.Views.Trip.New ;
$('#content').empty().append(new_trip.el) ;
},
showTrip: function(id){
console.log('trips id:' + id) ;
}
});
做链接看起来像什么处理,他们是如何构建的?如果他们在查看代码中,你可以包含这段代码? – 2013-03-25 05:52:43
您是否添加了事件处理程序来防止默认行为并调用'Backbone.history.navigate(...)'?链接将像平常一样行事,除非您明确地做其他事情。 – loganfsmyth 2013-03-25 05:52:53
@StuartM我的家链接纯粹是:'Home – 2013-03-25 06:52:34