0

説明:

jQuery メソッドの使用には興味がありません。

概要

HTMLのロードが完了した後にのみモジュールを実行する方法を使用しています。このように見えます。 page_completeページの最後の要素の ID です。

$A.finish('page_complete', function () { 
    // page has finished loading
});

Finishはこんな感じで実装。最後の要素の存在をチェックするのは単なるタイマーです。見つかったら、すべてのモジュールを初期化します。

FF が私に言っているように、要素が NULL である理由がわかりません。

/*finish
** Once an element has been loaded an HTML focus event is fired
** on that ID.  It can not be cancelled and bubbles up
**
*/
$A.finish = function (id, callback) {
    var htm_finished = document.getElementById(id);
    if (htm_finished) {
        $A.initAll(); // intilAll will fire the init function of all modules.
        $A.makeEvent('focus', htm_finished);
        callback();
    } else {
        setTimeout(function () {
            $A.finish(id, callback);
        }, 10);
    }
};

Firefox のエラー

...TypeError: this.E.ready is null @ ...

エラーがある場所にコメントを付けたことに注意してください。

エラーのあるモジュール

/*MUserAny
**
**
**   
*/
$A.module({
    Name: 'MUserAny',
    S: {
        DynSma: SDynSma,
        DynTwe: SDynTwe,
        DynArc: SDynArc,
        AniFlipMediaPane: SAniFlipMediaPane,
        AniFlipPage: SAniFlipPage,
        ClientStorage: SClientStorage
    },
    E: {
        ready: $A('#page_complete')[0]
    },
    init: function () {
        var pipe = {},
            this_hold = this;
        this.E.ready.addEventListener("focus", function (event) { // error is here.
            pipe = $A.definePipe(this_hold.Name);
            $A.machine(pipe);
        }, false);
    },
    pre: function (pipe) {
        var h_token = this.S.ClientStorage.get('h_token');
        if ((h_token === '0') || (h_token === 'undefined') || (h_token === null)
                || (h_token === undefined)) {
            this.S.AniFlipPage.run('sp');
            pipe.state = false;
        } else {
            pipe.server.smalls.h_token = h_token;
            pipe.state = true;
        }
        this.S.AniFlipMediaPane.run('mi_cover');
        return pipe;
    },
    post: function (pipe) {
        this.S.DynSma.run(pipe.server.smalls);
        this.S.DynArc.run(pipe.server.arcmarks);
        this.S.DynTwe.run(pipe.server.tweets);
        this.S.AniFlipPage.run(this.S.ClientStorage.get('page'));
        return pipe;
    },
    finish: function (pipe) {
    }
});
4

1 に答える 1

1

のように見えます

E: {
    ready: $A('#page_complete')[0]
}

オブジェクト リテラルの一部として評価されており、ページが完了する前にこれが発生すると、エラーが発生します。手っ取り早い解決策の 1 つは、関数に変更することかもしれません。この関数は、ページの完了後に発生することがわかっているときE.readyにのみ呼び出されます。次のようなものです。init

E: {
    ready: function() { return $A('#page_complete')[0]; }
},
init: function () {
    var pipe = {},
        this_hold = this;
    this.E.ready().addEventListener("focus", function (event) { ...
于 2013-01-06T22:18:52.033 に答える