Unexpected page change

Unexpected page change

I have a cordova/jQuery Mobile app which has a single HTML page, many jQuery-Mobile page divs and, amongst other things, page switches of the type:

  1. someDiv.unbind('tap').on('tap', function(){
  2.       $('body').pagecontainer('change', $('#someotherpage'));   
  3. });

(The whole code is quite large now, so I can't upload the whole thing).

Broadly, this is working fine. But I'm getting spurious page changes. For example:

I tap on a div in Page A
...the page changes correctly to Page B
I tap on the back button
...the page changes correctly back to Page A
I tap on the same div in Page A
...the page changes correctly to Page B
...but now, I see a page change event going from Page B to the home page of my app.

After many hours of looking, I cannot for the life of me see what is causing this second page change. It is definitely from Page B (not from Page A), but I've trapped all events that I can see that might lead to it and none of them are firing.

Does anyone know a way, in the "pagebeforeshow" event or any of the others, to identify the series of events that led to the page switch?

By the way, this happens intermittently (but often) on both a real iPhone and a real Android phone, but not on the Intel XDK emulator.