在jquery ui对话框中加载骨干js视图iframe

Loading backbone js view iframe inside jquery ui dialog

本文关键字:js 视图 iframe 加载 jquery ui 对话框      更新时间:2023-09-26

我正在为报告的iframe创建一个视图。

<div id="aDialog"></div>

这里是ReportView:

define(["jquery" ,
    "underscore" ,
    "backbone",
],function($, _, Backbone){
  var ReportView = Backbone.View.extend({
     el : "#agingFrame",
     initialize: function() {
         this.$el.html('<iframe src="http://ipadressofreportserver/jasper/blahblah"></iframe>');
     },
     render: function(){
     }
   });
   return ReportView;
});

然后我有另一个视图,可以让用户打印上面的iframe,这是主视图的动作:

 'printingReportIcon' : function(){
    var page = "http://localhost/Source/#ReportView";
    var $dialog = $('#aDialog')
            .load(page)
            .dialog({
                autoOpen: false,
                modal: true,
                height: 625,
                width: 500,
                title: "Some title"
            });
    $dialog.dialog('open');

对话框打开,所有源代码在ReportView中,但没有iframe。

知道是什么原因造成的吗

我不确定,但我认为问题是ReportView没有在第二个视图上实例化(渲染)。你只是得到那个视图的相对url,而不是渲染内容。

尝试:

  • 使用render方法渲染ReportView中的内容。
  • 返回此内容并使用它来打开对话框。

我想这就是问题所在。

希望有所帮助