【问题标题】:requirejs on a windows phone 7Windows Phone 7上的requirejs
【发布时间】:2012-12-13 06:53:16
【问题描述】:

所以我之前问了一个关于带有主干和 jquery 和 require 的 windows phone 7 的问题。

我继续对此进行调查并将其剥离到最低限度

以及刚刚拥有的索引页面

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

然后是一个只有一个 jQuery 路径的 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 在内的所有其他浏览器上执行此操作!

谁能帮忙?

【问题讨论】:

    标签: windows-7 requirejs


    【解决方案1】:

    不确定您是否使用 Phonegap,如果没有,您应该使用(或等效框架)。

    如果您按照此处的说明进行操作enter link description here

    查看生成的 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 就绪”事件

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-10
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多