开发者

how to load extjs require files with php?

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开发者_如何学Go set requires: [....] dynamically before application load with php? like maybe with a ajax call or something?

Regards


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜