jashkenas / backbone

Give your JS App some Backbone with Models, Views, Collections, and Events
http://backbonejs.org
MIT License
28.1k stars 5.39k forks source link

Uncaught TypeError: Object #<Object> has no method 'replace' backbone.js:1357 #2841

Closed alexey-sh closed 10 years ago

alexey-sh commented 10 years ago

Hi guys,

Sometimes my site gets an error:

Uncaught TypeError: Object #<Object> has no method 'replace' backbone.js:1355
_.extend.getFragment backbone.js:1355
_.extend.navigate backbone.js:1473
_.extend.navigate backbone.js:1252
(anonymous function) app.js:58
(anonymous function) jquery-1.10.2.min.js:4
c jquery-1.10.2.min.js:4
p.fireWith jquery-1.10.2.min.js:4
(anonymous function) jquery-1.10.2.min.js:4
c jquery-1.10.2.min.js:4
p.fireWith jquery-1.10.2.min.js:4
k jquery-1.10.2.min.js:6
r jquery-1.10.2.min.js:6

My browser: Chrome/30.0.1599.101 My OS: Mac OS X 10.7.5 Backbonejs version: 1.1.0 The url: http://localhost:9020/#signin

This error began to appear yesterday. Could you please help with it? I really can't get this error manually.

Thank you

SBoudrias commented 10 years ago

Hey, I think this is a bug introduced in the lastest underscore. Try with version 1.4.

alexey-sh commented 10 years ago

Hi, SBoudrias I used version 1.5.1. What the latest version do you mean, 1.5.2 ?

SBoudrias commented 10 years ago

I just vaguely remember some people having a similar issue when switching from 1.4 to 1.5 (not properly a bug, mostly a breaking change in the way underscore handled things).

I'm just suggesting you to try your app with Underscore 1.4, if it works, then you can walk up your bug from there.

akre54 commented 10 years ago

Hi @suneq, can you post a small jsfiddle example showing the code that causes this problem? Do you have pushState enabled or disabled?

You can join the IRC channel and we'll try and help you out there.

alexey-sh commented 10 years ago

Hi, dear akre54! My app is large, so I can post only initializing code

app: {
    firstHash: location.hash,

    defaultHash: 'dashboard',

    init: function (Router) {

        location.hash = '';
        Backbone.history.start();
        this.router = new Router();
        // something code
        this.router.navigate(this.firstHash || this.defaultHash, {trigger: true})
    }
}

Thank you!

akre54 commented 10 years ago

If you can post a small sample of the problem code in a runnable, testable jsfiddle we can help you that way. Unfortunately that's not quite enough information to go on.