Page refresh takes to blank page in Backbone.js

446 Views Asked by At

I have an application in backbone.js. If I refresh any page with the # tags, the content of the page disappears. Can anyone suggest any solution for this.

Here are the codes of my main.js and app.js

main.js

require.config({
        paths: {
        jquery:     'libs/jqm/jquery-1.9.1.min',
        async:      'libs/require/async',
        jqm:        'libs/jqm/jquery.mobile-1.4.0-alpha.2.min',
        iscroll:    'libs/iscroll/iscroll',
        underscore: 'libs/underscore/underscore_amd',
        backbone:   'libs/backbone/backbone_1.1.0_min',
        text:       'libs/require/text',
    }
});
require(['app', 'jqm-config'], function(app) {
        app.initialize();
});

app.js

define(['jquery', 'underscore', 'backbone', 'router'], function($, _, Backbone, Router) {
    'use strict';
    var init=function(){
        var router = new Router();
        Backbone.history.start();
    };
    return{
        initialize:init
    }
});

Any help is greatly appreciated.

May be it is a duplicate of this. But none of the suggestions worked for me.

1

There are 1 best solutions below

0
On

I added async: false to each of the fetch method and it resolved.