0

それで、バックボーンとjqueryとrequireを備えたWindows Phone 7について以前に質問しました。

私はこれを調査し続け、それを最小限に減らしました

とちょうど持っているインデックスページ

 <script data-main="js/main" src="js/vendor/require/requireNew.js"></script>

そして、jQuery へのパスが 1 つしかない main.js

require.config({
//path mappings for module names not found directly under baseUrl
paths: {
    jquery:     'vendor/jqm/jquery_1.7_min'
}

});

alert('why');

$(document).ready(function() {
  alert('DOM IS READY ');
});    

Windows 7 では、なぜアラートが表示されますが、DOM はここにありません...

ie7を含む他のすべてのブラウザでこれを行います!!

誰でも助けることができますか?

4

1 に答える 1

0

Phonegap を使用しているかどうかは不明です。そうでない場合は、使用する必要があります (または同等のフレームワーク)。

こちらの指示に従う場合は、ここにリンクの説明を入力してください

生成された index.js を確認すると、デフォルトの phonegap WP7 アプリケーションを構築できます。

var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // `load`, `deviceready`, `offline`, and `online`.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of `this` is the event. In order to call the `receivedEvent`
    // function, we must explicity call `app.receivedEvent(...);`
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    }
};

「dom ready」イベントを取得する前に「device ready」イベントを待つ必要があるため、モバイル デバイスではもう少し複雑です。

于 2013-07-11T08:40:41.867 に答える