Got*_*dia 1 router backbone.js
只是想知道为什么我的路由器没有方法导航?
我已经new App.Router;打电话了.在我看来,我尝试调用我的索引视图:
addTrip: function(e){
e.preventDefault() ;
//Adding to collection
var newTrip = this.collection.create({
title: this.$('#new_trip #title').val(),
where: this.$('#new_trip #where').val(),
desc: this.$('#new_trip #desc').val(),
rating: this.$('#new_trip .active').text()
}, { wait: true }) ;
if(newTrip.validationError){
this.errorReport(newTrip.validationError) ;
}
this.clearForm() ;
//Navigate to home route
App.Router.navigate('', true) ;
}
Run Code Online (Sandbox Code Playgroud)
我在Chrome开发工具中收到以下错误:
Uncaught TypeError: Object function (){ return parent.apply(this, arguments); } has no method 'navigate'
我甚至试图从控制台调用导航,它似乎也没有工作.
我究竟做错了什么?
您应该在路由器对象上调用导航.看来你是在课堂上调用它.
App.myRouter = new Backbone.Router() //or if you have your own base router class App.myRouter = new App.Router()
myRouter.navigate('', true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1364 次 |
| 最近记录: |