Building iOS/Android mobile app using Backbone.JS, jQUeryMobile and HTML

Submitted by vadim on Sat, 05/26/2012 - 21:37

There are interesting researches made by Cisco and Ericsson that predicts incredible mobile traffic increase during next few years and a share of it will reach a share of PCs traffic by 2016.

Nowadays almost any major website has a mobile version or responsive/adaptive design that helps to view website on any device. These approaches are quite different, but they work good for content display only. What if you desire to build a rich HTML5 and JavaScript application which interacts with a server and renders pages using theme similar to iPhone or Android one? What kind of technology stack would you use for that?

In this blog post I will answer on the questions above and demonstrate you simple mobile web application that allows to view and save textual posts. There is a Python backend, that stores information in the MongoDB and communicates with a front end using REST approach. Front end is built with the Backbone.js and jQueryMobile.

Below are screenshots of the application (click to view big image in a new window):

Front-end technology stack

Backnone.js

Backbone.js is a JavaScript MVC framework based on Underscore.js, that helps to build complex JavaScript applications. It has Model, Collection, View and Router classes. Model and Collection communicates with a RESTful service, while View renders an HTML page. In View you can bind functions to both Model and DOM events, so if Model is updated, page will be re-rendered automatically. For more information about Backbone.JS, please, visit step-by-step tutorial, Backbone patterns, official reference or a demo app.

jQueryMobile

jQueryMobile is a useful JavaScript framework for building mobile apps. It provides mobile looking components such as lists, buttons, toolbars and dialogs. All mobile pages can be stored in a single HTML file in different divs. HTML file is processed by jQueryMobile that provides many effects for transitions between pages. There is also rich API that allows to interact with a user or to build pages in a DOM dynamically.

iOS Inspired jQueryMobile Theme

iOS Inspired is a special theme for jQueryMobile that makes your web app look and feel like native iOS application. You can also build your own theme with the ThemeRoller.

Back-end technology stack

CherryPy

CherryPy is a Minimalist Python Web Framework that allows to build simple web applications. In this project it is used for a REST server. In production mode CherryPy instances could be run on several servers.

MomPy

MomPy is a Python 3 compatible ORM (Object Relational Mapper) to use MongoDB with Python. It is not perfect but is ok for a demo app. I used it because Mongoengine is not ported to the Python 3 yet.

MongoDB

If you have ever think about scaling your project, you might think about making your database fast. MongoDB is a NoSQL document-oriented database that is easy to use and scale. It ideally works for applications that require big data storage and do not have ttransaction queries.

Backbone.js and jQueryMobile together

Approach

I discovered an interesting blog post by Christophe Coentraetes. He suggested how to use Backbone.js and jQueryMobile together. He disabled router of jQueryMobile and used one from Backbone.js, which made his app more solid. Though there is a side effect (you need manually define weather router item is page or dialog and write custom code to open it) benefit is obvious: you can manually render page in a DOM using Backbone.js.

Problems

In my demo app I used the same approach but now I understand that it is not perfect. See why:

  1. Every time when user goes to a next page, new one is created in a DOM, while previous one is removed. Same happens to models and collections too. This degrades benefits of Backbone.js. At least collections and models should be loaded in memory. Also in most cases we do not need to re-create most of the pages.
  2. Template handling isn't implemented in the best way, cause there are lot's of different files which needs to be loaded. I think that there should be single template for all pages written in e.g. Mustache. Moreover, elements such as header or footer, could be generated automatically.

Sources and further work

Of course, source code of this demo app is free to dowload. Follow my Github repository to watch updates in future. My plan is to construct skeleton/framework for building mobile applications easily using Backbone.js and jQueryMobile and as example I want to build simple social mobile application to allow people to share something.

15 comments

Great Post. I have not been

Submitted by Anonymous (not verified) on Mon, 06/10/2013 - 14:44.

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work. Harga iPhone : Harga BlackBerry Terbaru

Mobile marketing today is

Submitted by joana (not verified) on Thu, 06/06/2013 - 01:54.

Mobile marketing today is growing and more applications are being released.
Top 5 Server and Admin Applications for Android and iPhone

I do believe the ideas behind

Submitted by Anonymous (not verified) on Mon, 06/03/2013 - 16:48.

I do believe the ideas behind this can be so great. There may be much available as a result. I see so much received from the idea. facebook timeline covers

Reply to comment | Vadim Mirgorod

Submitted by StealthGenie Review (not verified) on Mon, 06/17/2013 - 10:56.

Nice post. I learn something totally new and challenging on sites I stumbleupon every day.
It's always helpful to read through content from other authors and use a little something from their sites.

Hi, Just for clarification

Submitted by Ricardo Montoya (not verified) on Fri, 05/24/2013 - 18:28.

Hi,
Just for clarification about the Problems section. I think you're not completely correct. It's a matter of programing. You can save the actual or other views in memory by using variables, arrays, etc. Then you just refer to them without any trouble.

I like this website. taxi in

Submitted by clapham100 (not verified) on Mon, 04/29/2013 - 10:12.

I like this website. taxi in Surrey | cab in Surrey

Wish me luck

Submitted by Best Android Tablet Apps (not verified) on Wed, 03/20/2013 - 20:51.

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface. Thanks for your teach, I will try myself. Wish me luck

Re - Building iOS/Android mobile app using Backbone.JS, jQUeryMo

Submitted by Logo Design (not verified) on Fri, 09/28/2012 - 12:09.

Thanks for sharing the technique and tips you have used before. As a beginner i always face some trouble in integration of Apps and other things with iOS.

Hello there

Submitted by Olly Richardson (not verified) on Tue, 07/24/2012 - 15:42.

The iOS inspired theme was very cool in the eyes. Besides, my mom have complimented that my phone have better theme background because a reader can easily get and read the thought on it. I am very glad for this! Thank you so much!

nice proposal essay

Submitted by beginner713 (not verified) on Mon, 05/20/2013 - 16:09.

nice
proposal essay

nice post proposal essay

Submitted by beginner713 (not verified) on Mon, 05/20/2013 - 15:44.

nice post
proposal essay ideas

Reply to comment | Vadim Mirgorod

Submitted by web design agency Berkshire (not verified) on Thu, 06/06/2013 - 08:25.

I like the helpful info you supply on your articles.
I'll bookmark your blog and take a look at again here regularly. I am moderately sure I will learn a lot of new stuff proper right here! Best of luck for the next!

great article

Submitted by delfo (not verified) on Fri, 06/15/2012 - 23:35.

sounds like the perfect couple on client side. willing to try it with processing.js on top.
whether the forecast will be confirmed or not guarantee flexibikity and pltform independency sounds like a great thing.
the maintenance and testing of apps on all the handsets on the market it's a monkey job

Thanks for sharing such great

Submitted by Smartkathy (not verified) on Tue, 06/12/2012 - 10:19.

Thanks for sharing such great information which is very useful to android developer who is trying to find Backbone.JS, jQUeryMobile and HTML. I am hoping to get some more new updates from your side.

خزانة المرأة، دولاب أنيق

Submitted by emily.bronte (not verified) on Sat, 05/18/2013 - 18:17.

Your post had provided me with another point of view on this topic
thanks
regard
emily.bronte
خزانة المرأة، دولاب أنيق