Two followup jQuery Mobile questions

This post is more than 2 years old.

An attendee from my jQuery Mobile presentation yesterday had some followup questions that I thought would be good to share with everyone. These kind of fall into the part tech/part opinion area so please feel free to argue with me.

Her first question is:

When developing a mobile website where the user submits data to the server, is it good practice to incorporate a "local storage" capabilities within the code in case the user's connection to the internet is temporarily lost?

I think the answer is - mostly yes. If you are building a jQuery Mobile web site that will be used via the mobile browser, then chances are the user is online already and will probably stay online. Having the form submit notice the user being offline on submission would be handy. Since the interruption is probably temporary thought I don't know if you need to store it. You could just handle it nicely and tell the user to try submitting again.

I think that's different than building an entire site that has some form off offline support. If you go that route, than you would definitely want to handle that for most forms. (Again, I won't say all forms. You wouldn't bother doing it for a search form for example.)

A simple solution may be to simply copy all form data to localStorage on form submit. If the form goes through, clear it out, if not, it stays in there and you can prefill the values on next visit.

Now for her next question:

I'm a .NET Developer and alot of the HTML elements require runat="server". I noticed you use ColdFusion. Can jquery mobile pages be created to work within the .NET framework, Ruby, and other programming languages?

Absolutely. At the end of the day, you are outputting HTML. Whether you use ColdFusion, PHP, or whatever, if you output HTML to the browser, then jQuery Mobile is going to be able to work with it. Now - I don't personally know a lot about .Net's runat stuff. It may be difficult to get that to output in the right format for jQuery Mobile, but at a high level, how you create your HTML should not matter. (So get those old Perl CGIs out if you want! :)

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Mike posted on 12/16/2011 at 1:53 AM

Hey Ray,

I caught the last couple of mins of your presentation yesterday and thought it was a really good intro to JQM, seems there are a lot of misconceptions of what JQM is and isn't.

on the last question in your post are you referring to a .net person returning html as in a webapp or in a mobile (phonegap) type app?

I'm assuming you are talking about a mobile web app and not a mobile app correct?

I have always thought if it was going to be in say phonegap you would then be returning JSON or something like that and parsing vs mobile web app that is run on the server.

Anyhow just a questions.

Comment 2 by Raymond Camden posted on 12/16/2011 at 2:00 AM

So in general, yes, if you mean a PhoneGap app hitting .Net (or ColdFusion), your CF/.Net should return data in a nice package (like JSON) that you then interpret on the PhoneGap side. You don't have to do that - you could return HTML fragments too.

Technically - it IS possible to push the user immediately to an offsite page. So the PhoneGap goes from (local)index.html to (remote)some.html. This works - and even still allows device hardware APIs. My old boss Greg Wilson did this once in PhoneGap. (But I don't think he blogged it.)

Comment 3 by Woody Pewitt posted on 12/16/2011 at 2:33 AM


Thanks so much for the presentation I got my first site using jQuery Mobile up last night. I look froward to doing much more with it soon!

Comment 4 by Raymond Camden posted on 12/16/2011 at 2:34 AM

Glad you liked it, Woody!