2013-05-22 2 views
1

아파치 코도바 버전 2.7을 사용할 때 문제가 있습니다. 브라우저에서 xampp에서 코드를 실행하면 코드가 제대로 작동하는 것 같습니다. 하지만 IOS로 컴파일하려고하면 그냥 작동하지 않습니다.require.js, backbone and cordova issue

파일로드시 파일 프로토콜 제한 때문에 핸들 바 템플릿과 html 파일을로드하는 데 사용되는 require.js 텍스트 플러그인과 관련된 문제 일 수 있다고 생각합니다.

또한 장치 준비 이벤트를 수신하지 않는 것과 관련이 있다고 생각하지만이 설정에서 올바르게 수행하는 방법을 모르겠습니다.

우리 main.js 코드는 다음과 같습니다 당신의 설정에서

require.config({ 
    shim: { 
     underscore: { 
     exports: '_' 
     }, 
     backbone: { 
     deps: ['underscore', 'jquery'], 
     exports: 'Backbone' 
     }, 
     handlebars: { 
     exports: 'Handlebars' 
     }, 
     flipBook: { 
     deps: ['jquery'] 
     }, 
     touchSlider: { 
     deps: ['jquery'] 
     } 
    }, 
    paths: { 
     jquery: 'libs/jquery', 
     jquerymobile: 'libs/jquery.mobile', 
     underscore: 'libs/underscore', 
     backbone: 'libs/backbone', 
     handlebars: 'libs/handlebars', 
     cordovaios: 'libs/cordova-2.7.0', 
     text: 'libs/text', 
     flipBook: 'plugins/flipbook.min', 
     touchSlider: 'plugins/jquery.touchSlider.min' 
    } 
}); 

// Includes File Dependencies 
require(["cordovaios", "jquery", "backbone", "routers/router"], function(
    cordova, $, Backbone, Router) { 
    // Set up the "mobileinit" handler before requiring jQuery Mobile's module 
    $(document).on("mobileinit", function() { 
     window.App = { 
     Models: {}, 
     Collections: {}, 
     Views: {}, 
     Routers: {} 
     }; 
     $.mobile.linkBindingEnabled = false; 
     $.mobile.hashListeningEnabled = false; 

     $(document).on('pagehide', 'div[data-role="page"]', function(event, ui) { 
     $(event.currentTarget).remove(); 
     }); 
     $(document).on('pagebeforeshow', 'div[data-role="page"]', function() { 
     $.mobile.showPageLoadingMsg(); 
     }); 
     $(document).on('pageshow', 'div[data-role="page"]', function() { 
     $.mobile.hidePageLoadingMsg(); 
     }); 
     document.addEventListener('touchmove', function (e) { 
     e.preventDefault(); 
     }); 
    }); 

    require(["jquerymobile"], function() { 
     // Instantiates a new Backbone.js Mobile Router 
     new Router(); 
    }); 
}); 

답변

2

당신이 텍스트 플러그인을 지정해야 야해. 기본 URL을 설정하고 플러그인을 설치하기 만하면됩니다. 나는

require.config({ 
    baseUrl: 'asesets/js/libs' 
}); 

그럼 내가 거기에 텍스트 플러그인을 계속 참조하는 프로젝트를 가지고 자동으로 참조를 선택합니다. 이것에 대한 단점은 당신이 다른 것들에 대한 경로 참조의 일부를 변경해야한다는 것입니다.

두 번째 문제는 준비중인 문서입니다. 나는 JS가 내 HTML의 맨 아래에 있기 때문에 장치가 준비되었는지 확인하지 않고 내 응용 프로그램이 작동하는 동안이 테스트를 수행하지 않습니다. 그러나 당신이 처음에 그것을 확인해야한다고 생각 어디 phonegap와 다른 영역이 있습니다. 그래서 당신이해야 할 일은 requirejs load 이벤트를 사용하는 것이라고 (다시 테스트하지 않은) 생각합니다. http://requirejs.org/docs/api.html#pageload

희망이 있습니다. 아마 오늘 밤 준비된 문서를 시험해보고 작동한다면 업데이트 할 것입니다.