Posts Tagged javascript

prevPage / nextPage in jQuery Mobile

Quick snippet in case this helps somone, because I’ve been stuck for an unreasonable amount of time on something that should have been straight-forward!

If you’re using the pageshow or pagehide event handling in jQuery mobile, you can find out which ‘pages’ the event is switching between. We can then inspect the object to find out the id of the page. First declare your function with two arguments as such:

function(event, ui) {...}

Now interrogate the passed “ui” variable as such (edit: updated to be much simpler):

$(ui.prevPage).each(function (){alert(this.id)})
ui.prevPage[0].id

I finally worked this out with a bit of reflection. To get more info about the ui.prevPage object, try passing it to this function:

function var_dump(object) {
    for (var member in object) {
        alert('Name: ' + member);
        alert('Value: ' + object[member]);
    }
}

An alternative, and actually what I’d now recommend,  would have been sticking a breakpoint inside the function and examining the “ui” object from your debugger (Firebug, WebKit Developer Tools, etc).

, , ,

No Comments

Button Hero – Can YOU press a button?!

Button Hero was a strangely fun little thing I made quite a while ago that got me a small amount of internet attention. I noticed it’s had a few visits lately for whatever reason, and I thought I’d move it from its old home at 110mb.com, a free hosting site, to this one. Two reasons, one it might help with the old SEO for this site, you never know, and two I think some people found they couldn’t access it at 110mb as that site is sometimes blacklisted as a haven for naughty internet practices like phishing.

Anyway, to make up for any inconvenience, I swapped out the now-defunct Last.fm player for a Grooveshark widget playing some songs I like and thought would fit.  Grooveshark is a site I heartily recommend, particularly if like some of my friends, you can’t find a Spotify invite. Let me know if you’ve got one to spare and I’ll pass it on with much thanks ;)

, , , , , , ,

No Comments