Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 对Sencha Touch 2中的选项卡更改发出Ajax请求_Javascript_Jquery_Ajax_Extjs_Sencha Touch - Fatal编程技术网

Javascript 对Sencha Touch 2中的选项卡更改发出Ajax请求

Javascript 对Sencha Touch 2中的选项卡更改发出Ajax请求,javascript,jquery,ajax,extjs,sencha-touch,Javascript,Jquery,Ajax,Extjs,Sencha Touch,我在sencha touch 2.4中工作,我希望在具有选项卡id的指定选项卡上有一个ajax请求。 我如何调用我的ajax函数,或者我只能通过按选项卡id单击指定的选项卡来获得请求?我正在使用Ext.define定义我的软件包和应用程序视图 我的代码: config: { tabBarPosition: 'bottom', items: [ { id: 'tab', t

我在sencha touch 2.4中工作,我希望在具有选项卡id的指定选项卡上有一个ajax请求。 我如何调用我的ajax函数,或者我只能通过按选项卡id单击指定的选项卡来获得请求?我正在使用
Ext.define
定义我的软件包和应用程序视图

我的代码:

config: {
        tabBarPosition: 'bottom',

        items: [

     {
                    id: 'tab',
                    title: 'Home',
                    iconCls: 'home',
                    styleHtmlContent: true,
                    scrollable: true,
                    items: {
                        docked: 'top',
                        xtype: 'titlebar',
                        title: 'MyTab'
                    }
                }
]
}
request: function() {
            Ext.Ajax.request({
            url: 'http://www.example.com'
            method: 'GET',
            callback: function(options, success, response) {
                Ext.ComponentQuery.query('#id')[0].setHtml( response.responseText );
            }
        });
    }
我的请求功能:

config: {
        tabBarPosition: 'bottom',

        items: [

     {
                    id: 'tab',
                    title: 'Home',
                    iconCls: 'home',
                    styleHtmlContent: true,
                    scrollable: true,
                    items: {
                        docked: 'top',
                        xtype: 'titlebar',
                        title: 'MyTab'
                    }
                }
]
}
request: function() {
            Ext.Ajax.request({
            url: 'http://www.example.com'
            method: 'GET',
            callback: function(options, success, response) {
                Ext.ComponentQuery.query('#id')[0].setHtml( response.responseText );
            }
        });
    }

要检测何时选择了选项卡,您可以使用panels focus事件收听该选项卡何时接收焦点,也可以收听tabpanel上的事件,该事件将在选择选项卡时触发。代码示例如下:

Ext.create('Ext.TabPanel', {
        fullscreen: true,
        tabBarPosition: 'bottom',

        defaults: {
            styleHtmlContent: true
        },

        items: [{
            title: 'Home',
            iconCls: 'home',
            html: 'Home Screen'
        }, {
            title: 'Contact',
            iconCls: 'user',
            html: 'Contact Screen'
        }],
        listeners: {
            activeitemchange: function() {
                console.log('active item changed');
            }
        }
    });

要实现这一点,您可以像上面一样使用
Ext.create
,也可以使用
Ext.define
来定义组件,然后使用create方法对其进行初始化

我已经更新了答案,很抱歉。正在调查这不起作用的原因我想使用Ext.define而不是Ext.application。很抱歉,我忘了这是针对ST2的,我指的是ExtJs解决方案。我已经重新写了答案。您可以使用任何方法来初始化您喜欢的代码。我刚刚用它运行了一个快速的示例。仍然没有侦听事件,我正在使用Ext.define。好的,我已经完成了这个解决方案,我正在将listners放在items数组中。