Antenna Aligner Part 5: Devil is in the detail

Posted by Chris George on Simple Talk See other posts from Simple Talk or by Chris George
Published on Fri, 01 Jun 2012 07:50:00 GMT Indexed on 2012/06/01 16:47 UTC
Read the original article Hit count: 330

Filed under:

"The first 90% of a project takes 90% of the time and the last 10% takes the another 200%"  (excerpt from onista)

Now that I have a working app (more or less), it's time to make it pretty and slick. I can't stress enough how useful it is to get other people using your software, and my simple app is no exception. I handed my iPhone to a couple of my colleagues at Red Gate and asked them to use it and give me feedback.

Immediately it became apparent that the delay between the list page being shown and the list being drawn was too long, and everyone who tried the app clicked on the "Recalculate" button before it had finished.

Similarly, selecting a transmitter heralded a delay before the compass page appeared with similar consequences.

All users expected there to be some sort of feedback/spinny etc. to show them it is actually doing something.

In a similar vein although for opposite reasons, clicking the Recalculate button did indeed recalculate the available transmitters and redraw them, but it did this too fast! One or two users commented that they didn't know if it had done anything.
All of these issues resulted in similar solutions; implement a waiting spinny. Thankfully, jquery mobile has one built in, primarily used for ajax operations.

Not wishing to bore you with the many many iterations I went through trying to get this to work, I'll just give you my solution! (Seriously, I was working on this most evenings for at least a week!)

The final solution for the recalculate problem came in the form of the code below.

$(document).on("click", ".show-page-loading-msg", function () {
           var $this = $(this),
               theme = $this.jqmData("theme") ||
                       $.mobile.loadingMessageTheme;
           $.mobile.showPageLoadingMsg(theme, "recalculating", false);
           setTimeout(function ()
                          { $.mobile.hidePageLoadingMsg(); }, 2000);
           getLocationData();
       })
       .on("click", ".hide-page-loading-msg", function () {
             $.mobile.hidePageLoadingMsg();
       });

The spinny is activated by setting the class of a button (for example) to the 'show-page-loading-msg' class.

Recalculate

This means the code above is fired, calling the showPageLoadingMsg on the document.mobile object. Then, after a 2 second timeout, it calls the hidePageLoadingMsg() function.

Supposedly, it should show "recalculating" underneath the spinny, but I've not got that to work. I'm wondering if there is a problem with the jquery mobile implementation. Anyway, it doesn't really matter, it's the principle I'm after, and I now have spinnys!

© Simple Talk or respective owner