2

I have that situation:

<form class="reqSnip" action="snipvw" method="post" target="_blank">
    <input type="hidden" name="a_snip" value="0">
    <input type="hidden" name="b_snip" value="1">
    <input type="hidden" name="fullDoc" value="true">
    <button type="submit" class="getFullSnippet"></button>
</form>

So - basic form with 3 hidden field+button to submit. With the help of jQuery I bind to the moment of submit this form and customize the process:

jQuery('.reqSnip').submit(function() {
    jQuery('#snipDIV').jqmShow(); // 1
    return false; // 2
});

To make picture clear:

  • // 1 - open some "pop-up-like" window over Web-page
  • // 2 - cancel form submit. I do so since the form just request some Ajax-info and must NOT perform standart form submission. For my question you can think as I just don't want the form submission take place, all Ajax-stuff is irrelevant for the question.

How all this works together:

  • In IE7/8/9/Chrome/Opera - all as expected, pop-up open, form don't submitted
  • In FireFox(ver. 8.0.1 on Windows XP SP3) - pop-up open and from DO submitted (so new tab appear in browser)

I make a light investigation in javascript debuggers (I just place 2 breakpoints(BP) on lines // 1 and // 2) and facts I discover:

  • IE7/8/9/Chrome/Opera - hit BP on line // 1, then BP on line // 2
  • FireFox - hit BP on line // 1 and NEVER hit BP on line // 2, so command 'return false' just never executed :(

So - how to make FF behaviour the same as in all others browsers?

P.S. Libraries used in line 1:

UPDATE

I found root of the problem... According jqModal documentation (see link above) if you bind to onShow event you must to show (set visible) the dialog (my "pop-up-like" window) inside the event handler. So the general scheme will be

var myOpen=function(hash){ hash.w.css('opacity',0.88).show(); }; 
$('#dialog').jqm({onShow:myOpen}); 
....
$('#dialog').jqmShow();

I wrote my code very close to this. All browsers accept this approach. FF "dislike" it. Have no idea why. So, to solve my problem it is enough DON'T bind to onShow event. That is!

Smarty
  • 1,579
  • 2
  • 11
  • 16
  • 1
    this works for me in FF8. have you tried clearing your browser cache and making sure you're running the code you think you're running and not some old version? – Hristo Dec 16 '11 at 15:56
  • I am very-very sure that I try execute exactly the same code as in my start message, just because Firebug for FF show me for sure which lines of javascript code browser get from server (or from cache, as you mention). The same for HTML code for form. I copied both code fragments directly from Firebug. So error/inaccuracy/obsolescence and other similar reason can be eliminated. – Smarty Dec 16 '11 at 17:59
  • If line 1 is hit but line 2 is not, that would normally mean line 1 threw an exception. What exception did it throw? – Boris Zbarsky Dec 16 '11 at 20:05

1 Answers1

0

Try this:

jQuery('.reqSnip').submit(function(e) {
    jQuery('#snipDIV').jqmShow(); // 1
    e.preventDefault(); // 2
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
  • I try you suggestion (thanks for it!). Didn't work, I am afraid. :( Line // 2 still no hit in control flow, so form continue to submit. – Smarty Dec 16 '11 at 18:09