JQuery – Where to add traditional calls

When I got started using this awesome extension to jQuery, I immediately found myself wanting to modify things on the page before the mobile plug-in was triggered.

As it turns out, the recommended solution is to simply put traditional jQuery calls before the reference that loads the mobile plug-in.

This way, your jQuery commands have a chance to run prior to the library being loaded. Here is the pattern to follow:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
 $(document).ready(function() {
  // Your jQuery commands go here before the mobile reference
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

Leave a Reply

Your email address will not be published. Required fields are marked *