2014-03-26 4 views
0

간단한 웹 작업 페이지가 있지만 코드가 실행되지 않습니다. 로드 기능 경고는 발생하지만 webworksready 기능은 실행되지 않습니다. 내가 뭘 잘못하고 있는지 모르겠다. js에서 문제가 될 수 있다고 생각하여 webworks.js 파일 자체를 직접 지적했습니다.webworksready 기능이 작동하지 않습니다.

<html> 
<head> 
    <title></title> 
    <link rel="stylesheet" type="text/css" href="css/bbui.css"> 
    <script type="text/javascript" src="js/bbui.js"></script> 
    <script type="text/javascript" src="js/webworks.js" ></script> 
    <script type="text/javascript"> 
    window.addEventListener("load", function(e) { 
     alert("load function"); 
     document.addEventListener("webworksready", function(){ 
      alert("Im in web works ready function"); 
     }); 
    }, false); 
    </script> 
</head> 
<body> 
</body> 
</html> 

답변

0

어떤 SDK를 사용하고 있습니까? 붙여 넣은 코드는 WebWorks v1 용이며 올바른 모양입니다. 그렇다면 장치/시뮬레이터 또는 브라우저에서 테스트하고 있습니까? 이 이벤트는 Chrome에서 방금 테스트하는 경우에는 발생하지 않아야합니다.

새로운 WebWorks 2 (Cordova 기반)를 사용하고 있다면, 상황이 조금 바뀌 었습니다. 당신은

<html> 
<head> 

<!-- cordova --> 
<script src="cordova.js"></script> 

<!-- initialization --> 
<script type="text/javascript"> 
    Application.initialize(); 
</script> 

<!-- cordova code, usually in another file, not inline, but either way... --> 
<script> 


var Application = { 

    // 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() { 
     blackberry.event.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() { 
     Application.receivedEvent('deviceready'); 

     // this is now, essentially your webworks ready function. 

    }, 

    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
     console.log('Received Event: ' + id); 
    } 
}; 

</script> 

...이 대신 같은 것을 할 것