jQuery UI tab beforeLoad preventDefault doesn't work


Judge God

Somehow the e.preventDefault()on beforeLoad()event in jQuery UI Tabs is not working properly. Here is a small example:

<div id="tabs">
    <ul>
        <li><a href="#exampleExistingTab">Existing Tab</a></li>
        <li><a href="/path/to/remote/tab">Remote Tab</a></li>
    </ul>
    <div id="#exampleExistingTab"><h3>Hello There!</h3></div>
</div>
<script type="text/javascript">
    $('#tabs').tabs({
        beforeLoad: function (e, ui) {
            e.preventDefault();
        }
    });
</script>

Make sure this is not a real script, just an example showing errors. I think the remote tab should never be loaded, but everytime you click on the "remote tab", the ajax request is fired (and it wasn't active before).

Anyone know this issue or how to fix it?

Tested: Mozilla Firefox 24.0; jQuery 1.10.2; jqueryUi 1.10.3

Russell

I'm not sure if e.preventDefault() will work like this in this case.

Since the "ui" parameter has a jqXHR object, have you tried doing the following:

ui.jqXHR.abort();

Related


jQuery UI tab beforeLoad preventDefault doesn't work

Judge God Somehow the e.preventDefault()on beforeLoad()event in jQuery UI Tabs is not working properly. Here is a small example: <div id="tabs"> <ul> <li><a href="#exampleExistingTab">Existing Tab</a></li> <li><a href="/path/to/remote/tab">

jQuery UI tab beforeLoad preventDefault doesn't work

Judge God The e.preventDefault()on beforeLoad()event in jQuery UI Tabs is not working properly. Here is a small example: <div id="tabs"> <ul> <li><a href="#exampleExistingTab">Existing Tab</a></li> <li><a href="/path/to/remote/tab">Remote T

jQuery preventDefault() doesn't work with .on()

Mr Gandy Yes, I've read many other articles with the same problem, but I don't understand how to fix this. I have created a bookmark button that needs to change the icon when clicked. my jQuery: jQuery(document).ready( function() { var bm = jQuery(".u

jQuery preventDefault() doesn't work with .on()

Mr Gandy Yes, I've read many other articles with the same problem, but I don't understand how to fix this. I have created a bookmark button that needs to change the icon when clicked. my jQuery: jQuery(document).ready( function() { var bm = jQuery(".u

jQuery preventDefault() doesn't work with .on()

Mr Gandy Yes, I've read many other articles with the same problem, but I don't understand how to fix this. I have created a bookmark button that needs to change the icon when clicked. my jQuery: jQuery(document).ready( function() { var bm = jQuery(".u

jQuery preventDefault() doesn't work with .on()

Mr Gandy Yes, I've read many other articles with the same problem, but I don't understand how to fix this. I have created a bookmark button that needs to change the icon when clicked. my jQuery: jQuery(document).ready( function() { var bm = jQuery(".u

jQuery preventDefault() doesn't work with .on()

Mr Gandy Yes, I've read many other articles with the same problem, but I don't understand how to fix this. I have created a bookmark button that needs to change the icon when clicked. my jQuery: jQuery(document).ready( function() { var bm = jQuery(".u

Bootstrap tab click preventDefault doesn't work

Stacey I'm using bootstrap 3.3 and following the tabs in the documentation. The simplest code given in the documentation doesn't work for me and I can't figure out why. $('#mainTabs a').click(function (e) { e.preventDefault() console.lo

Bootstrap tab click preventDefault doesn't work

Stacey I'm using bootstrap 3.3 and following the tabs in the documentation. The simplest code given in the documentation doesn't work for me and I can't figure out why. $('#mainTabs a').click(function (e) { e.preventDefault() console.lo

Bootstrap tab click preventDefault doesn't work

Stacey I'm using bootstrap 3.3 and following the tabs in the documentation. The simplest code given in the documentation doesn't work for me and I can't figure out why. $('#mainTabs a').click(function (e) { e.preventDefault() console.lo

Bootstrap tab click preventDefault doesn't work

Stacey I'm using bootstrap 3.3 and following the tabs in the documentation. The simplest code given in the documentation doesn't work for me and I can't figure out why. $('#mainTabs a').click(function (e) { e.preventDefault() console.lo

Bootstrap tab click preventDefault doesn't work

Stacey I'm using bootstrap 3.3 and following the tabs in the documentation. The simplest code given in the documentation doesn't work for me and I can't figure out why. $('#mainTabs a').click(function (e) { e.preventDefault() console.lo

jQuery preventDefault doesn't always work

myhappycoding I have a function called showBasket that shows you a list of items added to shoppingBasket. This happens whenever the user clicks the link. Every time you click outside the menu, it hides again. My problem is that in this menu I have a list of li

jQuery preventDefault() doesn't work in AJAX call

coronavirus disease So when the user enters an email, I'm checking if that email exists. $('form.recover-form#check-form').on('submit', function(e){ var form = $(this), input = $('.check-recover-email'), span = $('.recover-error')

jQuery preventDefault doesn't always work

myhappycoding I have a function called showBasket that shows you a list of items added to shoppingBasket. This happens whenever the user clicks the link. Every time you click outside the menu, it hides again. My problem is that in this menu I have a list of li

jQuery UI tab selection method doesn't work

Zach I have two tabs, each with a submit button. After the button is clicked, I need to reload the content of that particular tab to get the updated data from the server. if (validStatus()) { $.ajax({ //... success: reloadTab }); }

jQuery UI tab selection method doesn't work

Zach I have two tabs, each with a submit button. After the button is clicked, I need to reload the content of that particular tab to get the updated data from the server. if (validStatus()) { $.ajax({ //... success: reloadTab }); }

Kendo UI TabStrip e.preventDefault() doesn't work

DoubleVoid Two questions: 1.) e.preventDefault() is not working properly with Kendo UI TabStrip somewhere $("#tabstrip").kendoTabStrip().data('kendoTabStrip'); Appear. 2.) Imagine the user clicks another tab, but with unsaved changes. A dialog pops up asking

Kendo UI TabStrip e.preventDefault() doesn't work

DoubleVoid Two questions: 1.) e.preventDefault() is not working properly with Kendo UI TabStrip somewhere $("#tabstrip").kendoTabStrip().data('kendoTabStrip'); Appear. 2.) Imagine the user clicks another tab, but with unsaved changes. A dialog pops up asking

jQuery .click() event.preventDefault() doesn't work

Richard King: I'm building an extensible web application by putting scripts into a preset directory. The script needs to read the file header before going to the page, so I need to use .preventDefault() when I click the link and run some JScript first. Unfortu

jQuery's preventDefault doesn't work with generated forms

Signal I am trying to generate a form by clicking on a list of users and post the data using AJAX. The preventDefaultelement does not work. I want to validate the form using AJAX without reloading the page. my code: $(function(){ $("#members_list ul > li")

jQuery .click() event.preventDefault() doesn't work

Richard King: I'm building an extensible web application by putting scripts into a preset directory. The script needs to read the file header before going to the page, so I need to use .preventDefault() when I click the link and run some JScript first. Unfortu

jQuery .click() event.preventDefault() doesn't work

Richard King I'm building an extensible web application by putting scripts into a preset directory. The script needs to read the file header before going to the page, so I need to use .preventDefault() when I click the link and run some JScript first. Unfortun

jQuery event.preventDefault() doesn't work unless debugging

metal encoder I am trying to use this method in order to convert GET parameters to POST. I also want the anchors to be handled correctly even when the middle mouse button is clicked. This is how the event handler is bound: $(document).ready(function () { $

JQuery 2.1.4 preventDefault on form submit doesn't work

salipshitz I have an HTML form that I'm trying to handle with JQuery 2.1.4 by using event.preventDefault() in the .on('submit', function(event) {})method , but it just reloads even though I'm event.preventDefault()there. Here is my HTML, CSS and JS code: var g

jQuery preventDefault doesn't work after field validation

Jules The following code is designed to validate that the input is not Blankt and then submit the form via Ajax. After removing the validation it works fine, but in place preventDefault doesn't seem to work. $(document).on("keydown", "input[class='p']", functi

jQuery's preventDefault doesn't work with generated forms

Signal I am trying to generate a form by clicking on a list of users and post the data using AJAX. The preventDefaultelement does not work. I want to validate the form using AJAX without reloading the page. my code: $(function(){ $("#members_list ul > li")

jQuery event.PreventDefault doesn't work in user defined function

Mickey I am creating a function that will receive a URL and then display that URL in a lightbox. I'm having trouble with event.preventDefault() in a function, it says it's not a function in the error console. I've tried passing the event to the function explic