如何用php加载extjs需要的文件?

发布于 2024-12-01 02:52:59 字数 801 浏览 2 评论 0原文

在 extjs 4 桌面示例中,app.js 看起来像这样

Ext.define('MyDesktop.App', {
    extend: 'Ext.ux.desktop.App',

    requires: [
        'Ext.window.MessageBox',

        'Ext.ux.desktop.ShortcutModel',

        'MyDesktop.SystemStatus',
        'MyDesktop.VideoWindow',
        'MyDesktop.GridWindow',
        'MyDesktop.TabWindow',
        'MyDesktop.AccordionWindow',
        'MyDesktop.Notepad',
        'MyDesktop.BogusMenuModule',
        'MyDesktop.BogusModule',

//        'MyDesktop.Blockalanche',
        'MyDesktop.Settings'
    ],

    init: function() {
        // custom logic before getXYZ methods get called...

        this.callParent();

        // now ready...
    },
................... 

,那么是否可以在使用 php 加载应用程序之前动态设置 require: [....] ?就像 ajax 调用之类的?

问候

In the extjs 4 desktop example, app.js is looks like

Ext.define('MyDesktop.App', {
    extend: 'Ext.ux.desktop.App',

    requires: [
        'Ext.window.MessageBox',

        'Ext.ux.desktop.ShortcutModel',

        'MyDesktop.SystemStatus',
        'MyDesktop.VideoWindow',
        'MyDesktop.GridWindow',
        'MyDesktop.TabWindow',
        'MyDesktop.AccordionWindow',
        'MyDesktop.Notepad',
        'MyDesktop.BogusMenuModule',
        'MyDesktop.BogusModule',

//        'MyDesktop.Blockalanche',
        'MyDesktop.Settings'
    ],

    init: function() {
        // custom logic before getXYZ methods get called...

        this.callParent();

        // now ready...
    },
................... 

so is it possible to set requires: [....] dynamically before application load with php? like maybe with a ajax call or something?

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的位置 2024-12-08 02:52:59

假设您的服务器中有 provider.php 作为设置提供程序,它输出 json,那么您可以执行类似...

var setting1, setting2; // and so on
var settingsStore = new Ext.data.JsonStore({
        proxy : new Ext.data.HttpProxy({
            url : 'provider.php',
            method:'GET'
        }),
        fields : ['setting1','setting2']
    });
 settingsStore.on('load',function(settingsStore,records,options) {
   if (records.length > 0) {
       setting1 = records[0].get('setting1');
       setting2 = records[0].get('setting2');
   }
 },this);

 // Now setting1 and setting2 variable contain your setting and available for used...
 Ext.define('MyDesktop.App', {
 extend: 'Ext.ux.desktop.App',

 requires:setting1,
 // ... and so on

编辑:
php 文件示例

$settings = array();
$settings[0] = array(
    'setting1' => array(
       'Ext.window.MessageBox',
       'Ext.ux.desktop.ShortcutModel',
       'MyDesktop.SystemStatus',
       'MyDesktop.VideoWindow',
       'MyDesktop.GridWindow',
       'MyDesktop.TabWindow',
       'MyDesktop.AccordionWindow',
       'MyDesktop.Notepad',
       'MyDesktop.BogusMenuModule',
       'MyDesktop.BogusModule',
       'MyDesktop.Settings'
    ),
    'setting2' => array(
       'Ext.window.MessageBox',
       'Ext.ux.desktop.ShortcutModel',
       'MyDesktop.SystemStatus',
       'MyDesktop.VideoWindow',
       'MyDesktop.GridWindow',
       'MyDesktop.TabWindow',
       'MyDesktop.AccordionWindow',
     ),
     // and so on
);

Header('Content-Type: application/json');
echo json_encode($settings);

assume you have provider.php in your server as setting provider, which outputing json, then you can do something like...

var setting1, setting2; // and so on
var settingsStore = new Ext.data.JsonStore({
        proxy : new Ext.data.HttpProxy({
            url : 'provider.php',
            method:'GET'
        }),
        fields : ['setting1','setting2']
    });
 settingsStore.on('load',function(settingsStore,records,options) {
   if (records.length > 0) {
       setting1 = records[0].get('setting1');
       setting2 = records[0].get('setting2');
   }
 },this);

 // Now setting1 and setting2 variable contain your setting and available for used...
 Ext.define('MyDesktop.App', {
 extend: 'Ext.ux.desktop.App',

 requires:setting1,
 // ... and so on

EDIT :
php file example

$settings = array();
$settings[0] = array(
    'setting1' => array(
       'Ext.window.MessageBox',
       'Ext.ux.desktop.ShortcutModel',
       'MyDesktop.SystemStatus',
       'MyDesktop.VideoWindow',
       'MyDesktop.GridWindow',
       'MyDesktop.TabWindow',
       'MyDesktop.AccordionWindow',
       'MyDesktop.Notepad',
       'MyDesktop.BogusMenuModule',
       'MyDesktop.BogusModule',
       'MyDesktop.Settings'
    ),
    'setting2' => array(
       'Ext.window.MessageBox',
       'Ext.ux.desktop.ShortcutModel',
       'MyDesktop.SystemStatus',
       'MyDesktop.VideoWindow',
       'MyDesktop.GridWindow',
       'MyDesktop.TabWindow',
       'MyDesktop.AccordionWindow',
     ),
     // and so on
);

Header('Content-Type: application/json');
echo json_encode($settings);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文