Created
April 5, 2012 17:48
-
-
Save zonak/2312804 to your computer and use it in GitHub Desktop.
jQuery mobile issue with r.js optimization
This file contains 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
// Spot A | |
window.document.onmobileinit = function() { | |
// this happens in both regular and optimized version | |
$.mobile.ajaxEnabled = false; | |
$.mobile.hashListeningEnabled = false; | |
$.mobile.pushStateEnabled = false; | |
$.mobile.linkBindingEnabled = false; | |
}; | |
require.config({ | |
paths: { | |
jquery: 'libs/jquery', | |
jquerymobile: 'libs/jquery.mobile' | |
// ... | |
} | |
}); | |
require(['jquery', 'ns', 'json2'], function($, NS) { | |
// Spot B | |
$(window.document).on('mobileinit', function() { | |
// this happens ONLY in the regular version, NOT in the optimized version | |
$.mobile.ajaxEnabled = false; | |
$.mobile.hashListeningEnabled = false; | |
$.mobile.pushStateEnabled = false; | |
$.mobile.linkBindingEnabled = false; | |
}); | |
// This is where jQuery mobile is loaded and at which point 'mobileinit' should be fired | |
require(['jquerymobile'], function() { | |
// ... | |
}); | |
}); |
jrburke
commented
Apr 5, 2012
Slight update on the matter.
For the time being, I took the following approach:
require(['order!jqmconfig', 'order!jquerymobile'], function() {
// ...
});
where jqmconfig
is a small module containing a definition of a listener with the necessary jQuery mobile overrides:
$(window.document).on('mobileinit', function() {
// this happens ONLY in the regular version, NOT in the optimized version
$.mobile.ajaxEnabled = false;
$.mobile.hashListeningEnabled = false;
$.mobile.pushStateEnabled = false;
$.mobile.linkBindingEnabled = false;
});
the order
plugin helps in making sure that the proper order of things is retained - defining the listener before the mobileinit
event fires.
@jrburke thank you again for looking into it. Looking forward to 1.1 - hopefully it will render this workaround unnecessary.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment