1

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);
                            }
                        }
                    ]
                }
            ]
        }
    ]
}
});
4

2 に答える 2

0

私はハンドラーをあまり使用しませんが、Tap Events の方が好きです。

問題はその選択かもしれません。

さらに、私があなただったら、Id ではなく ItemId を使用し、getComponent() ではなく getCmp() を使用します。

検索ボタンは同じビュー フォームにあるため、値を取得できます。

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

これらの推奨事項を作成します。グローバル オブジェクト (id や getCmp など) を使用しているときに、sencha で多くの奇妙な動作を経験しましたか? itemId と getComponent() を使用する方が安全です。

于 2013-07-10T16:36:01.283 に答える