Questions tagged [preventdefault]

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

960 questions
15
votes
6 answers

how prevent submit on press enter in twitter bootstrap typeahead plugin

I have a input text and I apply it typeahead plugin for suggesting items, but when I press enter key on input text it submit form. How can I prevent form submit using twitter bootstrap typeahead plugin?
paganotti
  • 5,591
  • 8
  • 37
  • 49
13
votes
3 answers

Angular2 EventEmitter and preventDefault()

Is there a way in Angular2 to somehow prevent the default for events using the EventEmitter? I have the following scenario: import {Component, Output, EventEmitter} from 'angular2/core' @Component({ selector: 'my-component', template: `
seraph
  • 351
  • 1
  • 3
  • 12
12
votes
3 answers

how to prevent default on keypress for certain event but then bring back the default again

I have been working on something that requires me to use the space bar to trigger an event. The thing I've been working on is much more complex but i've simplified it down to basics as an example of what I needed to do. The idea is that when the…
Suzi Larsen
  • 1,420
  • 5
  • 18
  • 32
12
votes
1 answer

Strange behavior with preventDefault() and radio buttons

See this jsFiddle: http://jsfiddle.net/nathanfriend/vAcpc/9/ It seems that the preventDefault() method doesn't prevent the clicked radio button from toggling (notice that the message always says "This radio button was checked", regardless of its…
Nathan Friend
  • 12,155
  • 10
  • 75
  • 125
11
votes
3 answers

preventDefault() not working on SELECT elements in Firefox 9.0.1

I realise there are other questions on preventDefault() not working with Firefox, but they did not help me. I've got three SELECT lists, and all I want is to navigate between them using the arrow keys without changing any values. The code works…
Ace
  • 1,392
  • 3
  • 14
  • 20
11
votes
5 answers

ReactJS - Cannot read property 'preventDefault' of undefined

Trying to do a simple onClick event/function, in ReactJS. When the button is clicked, I want to run a function called "onClick", but I get this error in console: app.js:62 Uncaught TypeError: Cannot read property 'preventDefault' of…
Reena Verma
  • 1,617
  • 2
  • 20
  • 47
11
votes
3 answers

evt.preventDefault is not working in IE and Edge on mouse move event, even tried evt.returnValue = false; but didn't work to stop propagation

I have a re sizable div. While trying to resize it the whole page is getting selected with blue color even though I didn't intend to in iE and Edge. I have tried many solutions shown on web but nothing worked. Below is my code. I am unable to…
Labeo
  • 5,831
  • 13
  • 47
  • 77
11
votes
4 answers

PreventDefault alternative for IE8

Situation: Trying to modify VideoJS.com in order to work with IE8 and Youtube Chromeless API. Problem: Progressbar dragging doesn't work (error on event.preventDefault(); 'not supported' according to debug) Demo:…
MeProtozoan
  • 1,027
  • 3
  • 14
  • 26
10
votes
2 answers

If conditions false then prevent default

I have a link. When some one clicks on that I want to check some conditions before letting it work. If it's false the default action should be prevented. $(".pager-next a.active").click(function(event) { if (!a == 1) { …
esafwan
  • 17,311
  • 33
  • 107
  • 166
10
votes
2 answers

Use JQuery preventDefault(), but still add the path to the URL

I am working on a website where clicking on a certain link will slide down a login panel. I am using event.preventDefault() to stop the site from redirecting as well as an animation event to slide the panel down. When the link is clicked, the panel…
JGDev
  • 261
  • 1
  • 4
  • 8
10
votes
1 answer

how to handle an "enter" in a q-input / preventDefault on submit?

I have a text input field, something like:
dcsan
  • 11,333
  • 15
  • 77
  • 118
10
votes
9 answers

Select2 4.0.0 AJAX - Choose highlighted option with Tab

I'm fetching user IDs and names via AJAX and using Select2 to search through them, but my users have requested the ability to select from the typeahead dropdown by pressing Tab, effectively treating it like pressing Enter. Here is my select2…
MikeOShay
  • 522
  • 1
  • 7
  • 17
10
votes
2 answers

Why does preventDefault() on a parent element's click 'disable' a checkbox?

I encountered this situation recently (simplified here). Simply wrap a checkbox with an element and apply preventDefault() on it's click event and the checkbox becomes uncheckable. See this fiddle, but here's a snip:
peteorpeter
  • 4,037
  • 2
  • 29
  • 47
10
votes
2 answers

IE Error with e.preventDefault

I apologise in advance if this has already been covered but I’m new to this, I have seen there are other similar posts but none of them have helped so I am thinking there might be another issue. I have a modal popup and it works fine in Chrome but…
Andy
  • 101
  • 1
  • 1
  • 3
10
votes
1 answer

Cross browser preventDefault() without jQuery

I wrote this bind method and am having an issue in my preventDefault() method to work in IE. The callback line never executes. Can someone provide assistance? Thanks! var preventDefault = function (event) { if (window.event) {…
Tommy
  • 131
  • 1
  • 4
1 2
3
63 64