我对骨干很新,有一个我似乎无法解决或找到解决方案的问题。
我的网站上有骨干。我们在网站的一部分上使用骨干,在路线'/ route#...'
它运行良好并呈现所有视图但是当我离开此路线并转到另一个页面时,例如主页,但随后返回到主干应用程序,不会呈现任何视图。
我必须手动刷新页面。
我试图结束骨干历史记录并确保我的JS文件不会被请求两次。
还有其他人遇到过这个问题吗?
路由器设置:
queriesToolApp.AppRouter = Backbone.Router.extend({
routes: {
"all" : "index", // /queries listings view
"new" : "new", // /queries new report view
"show/:id" : "show" // individual get a new report show page
},
index: function() {
// Create a new instance of the queries collection
var queries = new queriesToolApp.Queries();
// Make a GET request and send the data to the view
queries.fetch({
success: function(reports) {
// On success render the view
var allReportsView = new queriesToolApp.AllReportsView({collection: reports});
// render the view
allReportsView.render();
}
})
},
new: function() {
// Create a new instance of the Account List Collection
var accountList = new queriesToolApp.AccountList();
// Grab the data from API
accountList.fetch({
success: function(accounts) {
// On success render the view
var accountListView = new queriesToolApp.AccountListView({collection: accounts});
// render the view
accountListView.render();
}
})
},
show: function(id) {
// create a new instance of the existing report and pass in the id
var report = new queriesToolApp.Query({id: id});
// grab 'this' context and call AJAX to get existing report data
report.fetch({
success: function(report){
// Create a new instance of the report keyword view
var reportKeywordView = new queriesToolApp.ReportKeywordsView({collection: report});
// Render the view
reportKeywordView.render();
}
})
}
})
由于