Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.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-从数字字段获取值_Javascript_Ajax_Html_Dom_Sencha Touch - Fatal编程技术网

Javascript Sencha Touch-从数字字段获取值

Javascript Sencha Touch-从数字字段获取值,javascript,ajax,html,dom,sencha-touch,Javascript,Ajax,Html,Dom,Sencha Touch,我刚刚开始使用Sencha Touch 2框架,在跨设备复制表单行为方面遇到了一些困难。我有一个简单的搜索栏,用户在其中输入一个值(所有数字),并选择它代表的内容(帐户、订单或电话号码)。当用户单击/点击搜索按钮时,它会获取输入字段的值和当前按下的数据类型按钮,并对PHP脚本进行AJAX查询。在PC上,它可以正常工作。在iPad(6.1.3)上,GET请求不会命中服务器,即使字段已填充,getValue函数也会报告NULL。我错过了什么 Ext.define('bazooka.view.Main

我刚刚开始使用Sencha Touch 2框架,在跨设备复制表单行为方面遇到了一些困难。我有一个简单的搜索栏,用户在其中输入一个值(所有数字),并选择它代表的内容(帐户、订单或电话号码)。当用户单击/点击搜索按钮时,它会获取输入字段的值和当前按下的数据类型按钮,并对PHP脚本进行AJAX查询。在PC上,它可以正常工作。在iPad(6.1.3)上,GET请求不会命中服务器,即使字段已填充,getValue函数也会报告NULL。我错过了什么

Ext.define('bazooka.view.Main', {
extend: 'Ext.tab.Panel',
requires: ['Ext.form.Panel', 'Ext.form.FieldSet', 'Ext.field.Text', 'Ext.field.Email', 'Ext.field.TextArea', 'Ext.field.Number', 'Ext.SegmentedButton'],

config: {
    fullscreen: true,
    tabBar: {
        ui: Ext.filterPlatform('blackberry') || Ext.filterPlatform('ie10') ? 'dark' : 'light',
        layout: {
            pack : 'center',
            align: 'center'
        },
        docked: 'bottom'
    },
    items: [
        {
            title: 'Home',
            iconCls: 'home',
            html: 'This will have news and updates for the department of the currently authenticated user.'
        },
        {
            title: 'Lookup',
            iconCls: 'search',
            items: [
                {
                    xtype: 'toolbar',
                    ui: Ext.filterPlatform('blackberry') || Ext.filterPlatform('ie10') ? 'dark' : 'light',
                    docked: 'top',
                    items: [
                        {
                            xtype: 'numberfield',
                            id: 'viki_searchbox',
                            autoComplete: false,
                            autoCorrect: false,
                            docked: 'left',
                            maxWidth: '40%'
                        },
                        {
                            xtype: 'segmentedbutton',
                            id: 'viki_seg_btn',
                            allowDepress: true,
                            items: [
                                {
                                    id: 'account',
                                    iconCls: 'user'
                                },
                                {
                                    id: 'workorder',
                                    iconCls: 'time'
                                },
                                {
                                    id: 'telephone',
                                    iconCls: 'more'
                                }
                            ]
                        },
                        {
                            xtype: 'button',
                            id: 'viki_searchbutton',
                            docked: 'right',
                            iconCls: 'search',
                            handler: function() {
                                var searchtype = Ext.getCmp('viki_seg_btn').getPressedButtons()[0]["id"];
                                var searchvalue = Ext.getCmp('viki_searchbox').getValue();
                                Ext.Viewport.setMasked({
                                    xtype: 'loadmask',
                                    message: 'Searching...'
                                });
                                Ext.Ajax.request({
                                    url: 'viki.php',
                                    method: 'GET',
                                    headers: {
                                        "Content-Type": "application/xml"
                                    },
                                    disableCaching: false,
                                    params: {
                                        type: searchtype,
                                        sv: searchvalue
                                    },
                                    timeout: 3000,
                                    failure: function(response) {
                                        console.log("oops");
                                    }
                                });
                                Ext.Viewport.setMasked(false);
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
});

我不经常使用handler,我更喜欢Tap事件

问题可能在于这个选择

另外,如果我是你,我会使用ItemId而不是Id和getComponent()而不是getCmp()

由于您的搜索按钮位于同一视图窗体中,因此您可以检索值

searchbutton.getParent().getComponent('itemId').value;

我提出这些建议,在使用全局对象(如id或getCmp)时,我是否在sencha中经历了许多奇怪的行为。使用itemId和getComponent()会更安全。

看起来您的视图是一个数字字段。 如果用户输入包含非数字字符,则数字字段将返回null