Last active
December 11, 2015 17:28
-
-
Save kechol/4634253 to your computer and use it in GitHub Desktop.
use jQuery and jQuery Mobile with RequireJS. NOTES:
* do NOT use require-jquery.js
* use shim config
* load jquerymobile at last
* do NOT add jquerymobile to deps array in scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(['jquery'], function($) { // do NOT add jquerymobile in deps array. | |
| $(document).on("pageinit", "#alpha", function() { // #alpha => the id attr of div[data-role="page"] | |
| // your scripts... | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ({ | |
| // no minification, is done by the min task | |
| //optimize: 'none', | |
| baseUrl: 'scripts', | |
| appDir: "../", | |
| name: "main", | |
| out: 'scripts/main.js' | |
| paths: { | |
| "jquery": "vendor/jquery.min", | |
| "jquerymobile": "vendor/jquerymobile.min", | |
| "jquery.validate": "vendor/jquery.validate.min", | |
| "underscore": "vendor/lodash.min", | |
| }, | |
| shim: { | |
| 'underscore': { exports: "_" }, | |
| 'jquery': { exports: "$" }, | |
| 'jquery.validate': ['jquery'], | |
| 'jquerymobile': ['jquery', 'mobileinit'] | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require.config( { | |
| paths: { | |
| "jquery": "vendor/jquery.min", | |
| "jquerymobile": "vendor/jquerymobile.min", | |
| "jquery.validate": "vendor/jquery.validate.min", | |
| "underscore": "vendor/lodash.min" | |
| }, | |
| shim: { | |
| 'underscore': { exports: "_" }, | |
| 'jquery': { exports: "$" }, | |
| 'jquery.validate': ['jquery'], | |
| 'jquerymobile': ['jquery', 'mobileinit'] | |
| } | |
| }); | |
| // Includes File Dependencies | |
| require([ | |
| // libraries | |
| "jquery", | |
| "underscore", | |
| "jquery.validate", | |
| // other files | |
| "alpha", | |
| "beta", | |
| "jquerymobile" // load last | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(['jquery'], function($) { | |
| $(document).on("mobileinit", function() { | |
| //jqm configuration | |
| //$.mobile.ajaxEnabled = false; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment