2

As I'm working on a mobile version of our company website I ran into, what I believe is, an issue with the BlackBerry 10 browser. (I'm using the Q10, version 10.1.0.4181)

I'm using jQuery to bind to the submit event on a form to do an AJAX call, so I have a preventDefault, but it seems that BB10 seems to ignore this when using the SUBMIT button the browser provides.

It works fine when pressing the enter key or pressing the submit button of the form, but when I press the Submit button which is at the bottom of my browser (alongside with the previous/next buttons) it ignores the preventDefault (and return false) and still continues on submitting the form.

I've set up a jsfiddle which demonstrates this:
http://jsfiddle.net/e4AHZ/4/

The code I'm using to bind is:

$(function () {
    $(document).on('submit', 'form', function (e) {
        e.preventDefault();
        alert('done!');
        return false; // as final resort, no luck =(
    });
});

Anyone else who had this issue? Is there a possible fix/workaround?

Thanks!

2 Answers2

0

I have worked around this by adding action="javascript:void(0);" to you form (see updated fiddle http://jsfiddle.net/e4AHZ/11/).

I do not know if this is good enough but action="javascript:void(0);" is in fact part of a solution given to a similar question.

<form method="post" action="javascript:void(0);">
    <input type="text" name="field1" value="some msg" />
    <input type="text" name="field2" value="some msg" />
    <input type="submit" />
</form>
Community
  • 1
  • 1
fvan
  • 16
  • This seems like a reasonable solution. We currently use the action for the AJAX call, but I can move it to something like data-action and use that instead. I tried it without action before, which didn't work, so this might be a solution. I'm going to try it out and if it works out well I'll mark this as the answer! Thank you. – Michael Owens Aug 05 '13 at 15:03
0

You can also set the action to "javascript:ajaxfunction();" where "ajaxfunction()" is the function you want to call to submit the form:

$('form').attr("action","javascript:ajaxfunction();");

This should allow you to take advantage of that submit button.

user17510
  • 50
  • 6