FAQ Database Discussion Community


preventDefault not working when multiple buttons with the same class

jquery,html,onclick,preventdefault
I have a button that appends some form elements to a div. The thing is, the button is duplicated on append as well. On first click of "add" button, another row of form elements is added. When I click on the "add" button that was added from first click (to...

sweetAlert preventDefault and return true

jquery,return,preventdefault,sweetalert
I tried sweeAlert plugin, which works perfectly, but I cant figure out how to do default stuff after confirm. $(document).ready(function () { function handleDelete(e){ e.preventDefault(); swal({ title: "Are you sure?", text: "You will not be able to recover the delaer again!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, delete!",...

Variable used on function with a dynamic value doesn't allow me to send form through ajax

javascript,jquery,ajax,preventdefault
I have many answer forms on a page with different classes for all the forms. all the forms got 2 buttons to send the parent form. I send the form if #avote_down or #avote_up is clicked, then got the parent form class of the button clicked and save the class...

preventDefault on mouse up

javascript,contextmenu,fabricjs,preventdefault
this code doesn't work. How can I prevent context menu in fabrics? canvas.on('mouse:up', function(options) { if(options.target){ switch(options.e.button){ case 0: // left click break; case 2: // right click options.e.preventDefault(); break; } } }); ...

jQuery Toggled search form will not submit once event.preventdefault

jquery,html,forms,input,preventdefault
I have a search form in my navigation bar that toggles open and closed when the user clicks the search button, using e.preventDefault() to prevent the search button from submitting the form, initially. Unfortunately, this functionality seems to be preventing form from submitting at all. I've tried using this jQuery...

kendo ui grid prevent posting data on client side validation error

post,kendo-ui,kendo-grid,preventdefault
I have done some clientside validation. parameterMap: function(options, operation) { if (operation !== "read") { var valid = customValidation(options); console.log(valid); if (valid) { return JSON.stringify({ discountPromotionViewModel: options }); } } }, And if the customValidation method returns false i don't want the grid to post the data. Now it posts...

Jquery prevent default doesn't work in wordpress

javascript,jquery,wordpress,preventdefault
I have tried by following code to prevent default of form submitting, but it doesn't work. What is problem to that. <div class="section-register"> <form id="registerform" novalidate="novalidate" method="post" action="http://localhost/yify2/wp-login.php?action=register" name="registerform"> <input id="wp-submit" class="button button-primary button-large" type="submit" value="Register" name="wp-submit"> </form> </div> My script is : <script type="text/javascript"> jQuery(document).ready(function() {...

Struts2 / jQuery: resume link href redirect after e.preventDefault();

jquery,jsp,struts2,preventdefault
On my Struts2 application, I have some buttons that will delete items from a table. So far, so good. Now, I'm trying to use jQuery to present the users with an alert to confirm if they really want to delete the chosen item. To do this, what I have in...

Stopping propagation on multiple hover event

javascript,jquery,javascript-events,each,preventdefault
My home page contains multiple boxes. On each boxes, when mouseover in or out , the title disappears and the content appears. It works fine. The problem is that when mouseovering more than one box on a short period of time, it is a mess. $( ".views-field-wrapper" ).each(function(){ $( this...

How to hide “react-bootstrap modal” form that has preventDefault() inside its onSubmit?

hide,reactjs,preventdefault,onsubmit,react-bootstrap
The problem is that when I do not use preventDefault(), page is reloaded onSubmit and hidden. When preventDefault is used my form is doing what it has in onSubmit, but it is not hiding after submit. When I use other "Close" button that has only onClick={this.props.onRequestHide} form is hiding just...

Disable arrow key page scrolling in Firefox

javascript,jquery,firefox,preventdefault
I have a project where the arrow keys can be used as a method of input, in most browsers simply using .preventDefault() works perfectly, however Firefox (v37 on both Win8 and OSX) still seems to move the browser window (If there's available off screen scroll-able area) $(document).keyup(function (evt) { if...

jQuery preventDefault() stops onclick from working

jquery,preventdefault
I have a problem with jQuery preventDefault from running the onclick function of an tag. Here is my example: Avoid page jump on # click $("#main a").bind("click", function (e) { e.preventDefault(); }); I thought preventDefault would stop the default event (href="#"). But that it would let the "onclick" event stil...