从该视图中创建一个新的 Backbone 视图

Create a new Backbone view from within that view

如何从该视图中创建新的 Backbone 视图?例如;我的观点 ModalDialog1 需要在 ModalDialog2 关闭时(重新)实例化自身。

define('ModalDialog1.View',
    [
        'modal_dialog1.tpl'
    ,   'ModalDialog2.View'
    ,   'Backbone'
    ,   'underscore'
    ],
    function(
        modal_dialog1_tpl
    ,   ModalDialog2View
    ,   Backbone
    ,   _
    )
{
    'use strict';

    return Backbone.View.extend({
        template: modal_dialog1_tpl

    ,   events: {
            'click a[data-modal-id="why-need-info"]': 'openModalDialog2'
        }

    ,   openModalDialog2: function() {

            var self = this;

            var closeCallback = function() {
                // How to reinstantiate this view/self??
                var modalDialog1 = new self();

                modalDialog1 .showInModal();  
            }

            var view = new ModalDialog2View({closeCallback: closeCallback})
                .showInModal();
                // On calling showInModal the current modal view (this) is destroyed
        }

    ,   getContext: function()
        {
            return {

            }
        }
    })
});

您可以使用相关视图的构造函数。

var modalDialog1 = new self.constructor();
modalDialog1.showInModal();

第二个选择是有一个方法在 modalDialog2 关闭时初始化 modalDialog1