骨干路由器没有导航的方法 [英] Backbone Router has no method navigate

查看:150
本文介绍了骨干路由器没有导航的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道为什么我的路由器没有方法导航?

Just wondering why my router has no method navigate?

新App.Router; 正常调用。在我看来,我试着打电话给我的索引视图,像这样:

I have new App.Router; called properly. And in my view I try to call my index view like so:

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

}

我收到以下错误Chrome开发工具:

I get the following error in Chrome Dev Tools:

未捕获类型错误:目标函数(){返回parent.apply(这一点,参数); }没有方法'导航'

我甚至试着打从控制台导航和它似乎没有擦出火花。

I even tried to call navigate from the console and it doesnt seem to work either.

我在做什么错了?

推荐答案

您应该调用浏览你的路由器的对象。看来你调用它的类本身。

You should call navigate on your router object. It seems you are calling it on the class itself.

App.myRouter = new Backbone.Router() //or if you have your own base router class App.myRouter = new App.Router() 


myRouter.navigate('', true);

这篇关于骨干路由器没有导航的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆