インデックス関数をレンダリングしようとするとエラーが発生するのはなぜだろうと思いcannot call method render of nullます。ルーターの初期化が完了するまで、インデックス関数のレンダリングを待機させる方法はありますか?console.logsは、初期化でajax呼び出しが行われる前にインデックス関数がレンダリングしようとしていることを示唆しているようです
1.Uncaught TypeError: Cannot call method 'render' of null gallery.js:231
2. XHR finished loading: "http://localhost:3000/readjsonfile". jquery.js:8241
3.success 
これがコードです。ルートがあります
var Gallery = Backbone.Router.extend({
routes: {
        "": "index",
    },
最初はnullに設定されています
 _index: null,
Galleryルーターの初期化では、インデックスがnullかどうかがチェックされ、nullの場合は、データを含む新しいビューが作成されます。
initialize: function(options) {
        var ws = this;
        if (this._index === null){
            $.ajax({
                url: 'galleries',
                dataType: 'json',
                data: {},
                success: function(data) {
                    console.log("success");
                    console.log(data);
                    ws._data = data;
                    ws._photos = new PhotoCollection(data);
                    ws._index = new IndexView({model: ws._photos});
                    console.log(ws._index);
                    Backbone.history.loadUrl();
                }, 
                error: function(r){
                    console.log("error");
                    console.log(r);
                }
            });
            return this;
        }
        return this;
    },
これは、初期化の直後に配置されたインデックス関数であり、上記の初期化で作成されたビューをレンダリングしますが、Cannot call method 'render' of nullエラーが発生します
index: function() {
        this._index.render();
    },