backbone.js - jquery mobile require.js and backbone -


i'm struggling require.js , jquery mobile. have loosely based file structure , loading pattern based off of

https://github.com/appboil/appboil-requirejs-backbonejs-jquerymobile-phonegap

but it's old , had make adaptions require 2.0 version. there community accepted way of using jquery mobile, backbonejs , requirejs together? i'd use backbone's routing , not jquery mobiles. additionally, template has phonegap, i'm not concerned with.

here main.js file use...

require.config({   baseurl: "/js/",   paths: {     jquery: 'libs/jquery/jquery-1.7.1',     'jquery.mobile-config': 'libs/jqm/jquery.mobile-config',     'jquery.mobile': 'libs/jqm/jquery.mobile-1.1.0',     'jquery.mobile.asyncfilter': 'libs/jqm/asyncfilter',     underscore: 'libs/underscore/underscore-1.3.3',     backbone: 'libs/backbone/backbone-0.9.2',     templates: '../templates'   },   shim: {           'underscore': {             exports: "_"           },           'backbone': {               //these script dependencies should loaded before loading               //backbone.js               deps: ['jquery','underscore'],               //once loaded, use global 'backbone'               //module value.               exports: 'backbone'           },           'jquery.mobile-config': ['jquery'],           'jquery.mobile': ['jquery','jquery.mobile-config'],           'jquery.mobile.asyncfilter': ['jquery.mobile'],         } });  require([   'jquery',   'app',   'jquery.mobile','jquery.mobile.asyncfilter' ], function( $, app ){     $(function(){       app.initialize();     }); }); 

the last bit important jqm load correctly (and function). part:

require([       'jquery',       'app',       'jquery.mobile','jquery.mobile.asyncfilter'     ], function( $, app ){         $(function(){           app.initialize();         });     }); 

since need jquery jqm (jquery mobile), i'll load them , shim code above, dependencies loaded in correct order. don't pass jqm variable function call, passes $ , app. next important part jqm-config file:

define(['jquery'], function ($) {       $(document).on("mobileinit", function () {           $.mobile.ajaxenabled = false;           $.mobile.linkbindingenabled = false;           $.mobile.hashlisteningenabled = false;           $.mobile.pushstateenabled = false;       }); }); 

you can place of preinit code jqm in file. after that, should able use jqm!


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -