Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jQuery Mobile and Backbone JS together in one app?

I've been enjoying using Backbone JS for a iPad HTML5 project... But I'm quickly running into a issue of needing iPad-ish transitions, form elements etc. After looking around, it seems jQuery Mobile is the most established. We use jQuery anyhow.

But one thing I quickly ran into was the hash events/ajax stuff of the two libraries quickly didn't work. Because jQuery Mobile takes care of loading in pages, and doing the transitions etc, it was not letting my Backbone Controller routes work as they did before. It seemed that the two aren't actually that compatible?

After some work though, I have a basic workaround... Using the page loading events stuff in jQuery Mobile to see the active page it's on and then fire the correct Backbone View that goes with that page. Basically doing away completely with Backbone's hash listening/routes/controller.

But this still doesn't seem right? How can Backbone JS and jQuery Mobile work seamlessly together? How do I do this right, moving forward?

like image 930
littlejim84 Avatar asked Apr 04 '11 11:04

littlejim84


People also ask

Do people still use jQuery Mobile?

The deprecation of jQuery mobile follows the careful transition of another project under the jQuery project umbrella, jQuery UI. jQuery Core is still actively maintained and widely implemented.

Is jQuery and jQuery Mobile the same?

jQuery and jQueryUI are both designed to be added to your website if you want to add a particular feature, jQuery or jQueryUI might be able to help. However, jQuery Mobile is a full framework which is built on jQuery and jQuery UI foundation.

Where should you place the jQuery Mobile js file?

jquery-mobile Getting started with jquery-mobile Setup Create a library (or lib) folder inside of your application (inside the www folder). Create a jquery-mobile folder inside the lib folder (I've named mine jqm). Place all of the jquery-mobile files that you have extracted inside of the jquery-mobile folder.


1 Answers

I think I found a solution when I asked the same question.

Disable the hash change controller in JQuery mobile UI and replace with backbone.js

There looks to be an option to disable JQuery hash change listening on a recent checking.

https://github.com/jquery/jquery-mobile/commit/3162428558efd9960739ef8f00a7ead0dbf6d3ec

I have not tried it yet though. If it works please let us know.

Brad

like image 159
bradgonesurfing Avatar answered Sep 27 '22 23:09

bradgonesurfing