Book Image

Mastering jQuery Mobile

Book Image

Mastering jQuery Mobile

Overview of this book

Table of Contents (17 chapters)
Mastering jQuery Mobile
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Working with RequireJS and Backbone.js


RequireJS and Backbone.js are two extremely popular JavaScript libraries. RequireJS is known as an asynchronous module definition script loader library that can improve page-load time as well as assist with dependency management. Backbone.js is a popular MVC framework. Both of these work great with jQuery Mobile, provided you get them to play together nicely.

To start getting into development with all three libraries, you have to turn off a couple of jQuery Mobile's properties. These two properties are:

  • $.mobile.linkBindingEnabled: This property allows jQuery Mobile to bind clicks to your anchor tags on the page.

  • $.mobile.hashListeningEnabled: This property enables jQuery Mobile to listen and handle changes to location.hash.

In order for Backbone.js or RequireJS to function properly with jQuery Mobile, both of these properties have to be set to false in our code. This code simply looks like the following:

$.mobile.linkBindingEnabled = false;
$.mobile.hashListeningEnabled...