0

In my app..

While i load the page or refresh the page my router not properly responding and calling the default view method. in case if i use other link to vist other hash url... works as well the back button doing fine.

Even while i load my page, my initiate function as well works fine. but the default method not triggering while i load the page and use the back button of the browser.

what cause this.. here is my code:

    define([
    "backbone",
    "../model/model",
    "../collection/collection",
    "../views/appView",
    "../views/listView",
    "../views/appViews"], 
    function(Backbone,appModel,collection,appView,listView,appViews){

    var appRouter = Backbone.Router.extend({
        routes:{
            "":"defaultView",
            "list":"listAItem",
            "add":"listViewIt"
        },
        initialize:function(){
            console.log("initiated....."); //works properly
        },
        defaultView:function(){
            new appViews(); // not working..
        },
        listAItem:function(){
            console.log("from listAItem"); 
                    // on click and using back button woks fine
        },
        listViewIt:function(){
            new listView();
                   // on click and using back button woks fine
        }
    });

    Backbone.history.start(); // removed and updated to where i call my app...

    return appRouter;
})

Now i updated my Backbone.history to call after initiating my app.. now my initial method (defual view called) but still while i use my back / font buttons in my browser not working.. but reset are works fine..

how to fix it..

here is my updated code:

 $.when.apply(null,requests).done(function(){
        var app = new router(); 
       //on refresh works, but not working while use back / front button of browser use.
        Backbone.history.start();
    });
4

1 回答 1

0

有用...

将初始元素设置为删除是我对其他视图的错误。现在我意识到了。现在工作正常。谢谢大家。。

更新代码:

this.$el.find("ul").html("<h1>New html has to come here</h1>");

它被错误地认为是:

this.$el.html("<h1>New html has to come here</h1>");
于 2013-05-20T05:31:53.443 回答