0

I'd like to know if is there a way to have a list of the default_event_actions for a particular element that 'event.preventDefault()' has been applied on and tell the script what event or action to prevent or not...

something like:

$(element).on('click', function(e){

e.preventDefault() //this will prevent all

//...is there a way of preventing specifically or particularly... 
}) 

Is it possible?

MPelletier
  • 16,256
  • 15
  • 86
  • 137
ErickBest
  • 4,586
  • 5
  • 31
  • 43

2 Answers2

1

You can use e.type to check type of event and based on condition can prevent default for example:

$(element).on('click', function(e){
    if(e.type == 'click')
        e.preventDefault(); //this will prevent all
    }
});
Dharmesh Patel
  • 1,881
  • 1
  • 11
  • 12
  • Thanks Man!...though, What a asking is what are those `defaults` your are preventing... is there a way to list them up?/// thx – ErickBest Oct 01 '13 at 10:05
  • There isn't any list of anything. Prevent Defaults means prevent default action. Means if you click a submit button it's default action is to submit form, so preventDefault prevents that default action attached with the element. – Dharmesh Patel Oct 01 '13 at 10:16
  • So you mean each element has a SINGLE SPECIFIC DEFAULT ACTION? are there elements with multiple Default Actions...? – ErickBest Oct 01 '13 at 10:46
0

You can use jQuery event namespaces to give unique name to your events : event.namespace

And to find all events attached to a particular element, you can look at Jonathan Sampson's answer for this question (Can I find events bound on an element with jQuery?)

Community
  • 1
  • 1
Elorfin
  • 2,487
  • 1
  • 27
  • 50
  • Thanx for this, though what a asking is what are those defaults are being prevented when apply `event.prevent()`... is there a way to list them up.. I got this from namespace: `` – ErickBest Oct 01 '13 at 10:07