【问题标题】:ExtJS load another app in panelExtJS 在面板中加载另一个应用程序
【发布时间】:2014-10-21 14:50:26
【问题描述】:

我正在尝试创建一个小型 ExtJS 应用程序(主应用程序),它在面板中显示其他应用程序(辅助应用程序)。我可以加载应用程序的索引文件,但没有加载 js 脚本。辅助应用程序已经构建。有谁知道我应该如何正确加载辅助应用程序?谢谢

这是我的主应用视图:

Ext.define('POCs.view.Main', {
extend: 'Ext.container.Container',
requires: [
    'POCs.controller.MainController',
    //'POCs.view.MainModel'
],

xtype: 'app-main',

controller: 'main',
viewModel: {
    type: 'main'
},

layout: {
    type: 'border'
},

items: [{
    xtype: 'panel',
    region: 'west',

    items:[{
          xtype: 'button',
          width:200,
          fontWeight: "bold",
          itemId: 'err',
          margin:20,
          html: 'POC1',
          bodyPadding: 10,
          handler: 'onErrButton' 

    },
    {     width:200,
          xtype: 'button',
          fontWeight: 'bold',
          itemId: 'per',
          margin:20,
          html: 'POC2',
          bodyPadding: 10, 
          //handler: 'onPerButton' 
    }
    ],

    width: 250,
    split: true,

},{
    region: 'center',
    xtype: 'panel',
    id: 'canvas1',
    name: 'Canvas1'


},
{
    region: 'north',
    xtype: 'panel',
    split:true,
    items:[{
        region:'west',
        xtype:'image',
        src:'logo.jpg'
        },
        {
            region:'center',
            html: '<h2>Proofs of concept</h2>',
            margin:"0 0 0 50",


        }]
}]
});

这是控制器:

Ext.define('POCs.controller.MainController', {
extend: 'Ext.app.ViewController',

requires: [
    'Ext.MessageBox'
],

alias: 'controller.main',

config: {
    refs: {
            canvas1: '#canvas1',
         }
},


init: function() {
   var me=this;

    me.control({
        '#per': {

                click: this.onPerButton,

                }   

    });
},
onErrButton: function () {
    Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},
onPerButton: function () {

    Ext.Ajax.request ({
        url: 'ap3init/index.html',
        scripts:true, 
        autoLoad:true,
        success: function(response) {
                 var htmlText= response.responseText;
                 var cp1 = Ext.getCmp('canvas1').setHtml(htmlText);
                  //setHtml only sets the html but doesn't activate the scripts

        }
    });

},
onSecButton: function () {
    Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},
onSpcnButton: function () {
    Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},
onSpcoButton: function () {
    Ext.Msg.confirm('Confirm', 'Are you sure?', 'onConfirm', this);
},

onConfirm: function (choice) {
    if (choice === 'yes') {
        //
    }
}
});

【问题讨论】:

标签: javascript ajax extjs model-view-controller


【解决方案1】:

正如 Perdro Reis 所建议的,解决方案是简单地使用 iframe 容器并加载其他应用程序的 html 文件。这不是最好的解决方案,因为我无法按预期加载 js 文件。

【讨论】:

  • 我的建议允许您在另一个面板中加载应用程序,并且您确实提到您有要使用的索引文件,我将其解释为具有 HTML 文件。我认为没有提到你只能加载 js 文件。但是,您可以在代码中设置 HTML 并在那里加载文件。我将不得不调查并可能稍后发布。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多