1

callParentが機能しない理由を理解しようとしています。

ここにいくつかのコードがあります:

Ext.define('AM.ArView', {
extend:'Ext.window.Window',
initComponent: function() {
    var foo = this;
    console.log(foo);

    Ext.Ajax.request({
        url: 'http://my/awesome/path',
        success: function(response, opts) {
            console.log(foo);
            foo.callParent();
        },
        failure: function(response, opts) {
            console.log('error');
        }
    });
}
});

エラー:キャッチされていないTypeError:未定義のプロパティ'superclass'を読み取れません

ajaxを介してWindowsアイテムをロードする必要があります

4

3 に答える 3

2

ダイアログにコールバックcallParentを渡す必要がありました。Ext.Msg.*正直なところ、私の場合の回答からコードを使用する方法を理解していませんでした...そしてハックでそれを解決しました。

4.0.7での作業:

methodName: function () {
    var me = this,
        args = arguments;
    // do some stuff
    function customCallback() {
        // do some stuff inside callback
        // hacks for calling parent method from callback
        var caller = arguments.callee.caller;
        caller.$owner = me;
        caller.$name = 'methodName';
        me.callParent(args);
    }
    // do more stuff, pass callback anywhere
}
于 2012-07-17T12:25:49.320 に答える
1

少し遅いですが、それが他の人に役立つことを願っています...

電話する代わりにthis.callParent();

あなたは電話する必要がありますthis.self.superclass.foo.call(this);

fooは、呼び出したいスーパークラスメソッドです。

それをまとめて、より意味のあるものに見せるために:

callParentManually: function (myscope, methodname) {
    myscope.self.superclass[methodname].call(myscope);
}

//and then ...
callParentManually(me, 'initComponent');

これを参照してください:

ExtJS4-callParentへの非同期コールバックが例外をスローします

于 2013-05-05T11:34:53.940 に答える
0

ヘイジュリアン!

同様の操作を行う必要があり、最終的にajaxリクエストを関数にラップして、リクエストが完了したときにコールバック関数を渡して実行し、コールバックからウィンドウを起動しました。

コードに関しては、次のようになります。

//Request function
 LoadThoseDamnWindows: function (callback)
    {
        Ext.Ajax.request({
            url: 'checklist/GetList',
            success: function(response, opts) {
                console.log(response);
                callback.call(this, response);
            },
            failure: function(response, opts) {
                console.log('error');
            }
        });
    }

次に、int Letsを呼び出します。たとえば、onaボタンをクリックします。

        {
                xtype: 'button',
                text: 'Help',
                iconCls: 'help',
                    scope: this,
                handler: function(){
                    //Call function
                    this.LoadThoseDamnWindows(function(loadedData){

                        Ext.create('Ext.window.Window',{
                            autoShow: true,
                            layout: 'fit',
                            title: "My Cool window",
                            html: "My window content with dynamic loaded data" + loadedData.responseText
                        });

                    });
                }
            }

HTH!

于 2012-02-13T22:03:00.787 に答える