0

How to stop the preventDefault() function and what is opposite function of the preventDefault() function. How to enable the links after call of ajax stop function?

putvande
  • 15,068
  • 3
  • 34
  • 50
waqar mirza
  • 555
  • 2
  • 15

4 Answers4

0

Simple don't use it!

If your link is :

<a href="www.google.com" id="myLink">link</a>

and your event is:

$('#myLink').click(function(){
console.log('no prevent')
//some code
return true:
});

after log you go to google...

grigno
  • 3,128
  • 4
  • 35
  • 47
0

You are using preventDefault() as

function(e){ e.preventDefault()};

and its opposite

function(e){ return true; }

Hope it will help you :)

Reference

Community
  • 1
  • 1
0

There isn't an opposite to preventDefault(). The opposite to that would be 'do default' which, of course, is done, by default. You need to run a condition that will decide whether the default is prevented, before preventing it.

//Your hypothetical 'do default'
e.preventDefault()
if(condition){
    e.doDefault(); //METHOD DOES NOT EXIST!
}

//How you should do it
if(!condition){
    e.preventDefault();
}
George
  • 36,413
  • 9
  • 66
  • 103
0
return false; e.preventDefault(); 

both work same it prevents the process and stop the execution

and about your question there is one option return true; to continue the execution of function.

I hope it will help to solve the problem.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Sonu Sindhu
  • 1,752
  • 15
  • 25