0

i've searched around and tried some solutions, but i can't get event.preventDefault() working on a simple page transition bind:

$("#trainingmodus").bind('pagebeforeshow', function(event, data) {
  event.preventDefault();
  console.log("trainingmodus going off screen ");
  app.canvasGeneralHide(function(){
     //data.deferred.resolve( data.absUrl, data.options);
  });
});

What i'd like to accomplish is to delay the page transition after some other transitions have finished. However, event.preventDefault() does not seem to be working.

In the documentation it's not explicitly stated if and how each function can use a callback, but i assumed that it would, just as the pagebeforeload listener?

I've looked at several other problems, like this one: e.preventdefault(); not working

I've also tried to use

event.stopImmediatePropagation();

or

event.stopPropagation();

which both had, alas, no effect.

Community
  • 1
  • 1
Michahell
  • 4,905
  • 5
  • 29
  • 45
  • Are you seeing your first log statement? try adding one before the prevent default and get rid of anything else like the app.general call make sure it is in fact the event prevent default statement causing the issue. also I havent seen a second param 'data' passed in anonymous functions for jQuery.bind . is this a jQuery mobile thing or common practice? – Alex Jun 22 '12 at 01:22
  • I suppose it's a jQuery Mobile thing. i've tried removing the second parameter, and commenting out everything except the event.preventDefault(). it just continues the transition to the next page, so that's definately causing the issue. I'm on OSX 10.7 using Google Chrome dev build bytheaway, should that matter. – Michahell Jun 22 '12 at 09:53
  • what is it that you are trying to accomplish. – Alex Jun 22 '12 at 17:49
  • well, i've stated that :) to quote myself: "What i'd like to accomplish is to delay the page transition after some other transitions have finished." - and then to continue the page transition, offcourse. in other words: delay it, and continue whenever i say it has to continue. – Michahell Jun 22 '12 at 18:59

1 Answers1

0

I think the prevent default would be in the transition event and not the before transition I do not think the before transition has a default event, like the default of clicking an a tag is to go to the address in the href attribute. Preventdefault would stop this from happening. what is the default behaviour of beforepagetransition? I think it doesn't have default behaviour it has to be defined explicitly.

I think you want to prevent the default of the actual transition until whatever you are waiting for is done

Alex
  • 502
  • 6
  • 14