아파치 코도바 버전 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();
});
});