preventdefault

Prevent JQuery Mobile swipe event over specific element

主宰稳场 提交于 2019-12-04 06:35:40
I am using jquery mobile and I need to prevent swipe event over specific element. Need of doing this is because I am using slider and I don't want the swipe event to be invoked resp. I want it to be prevented when user is manipulating with slider. I was not able to too find any solution so I am asking for help here. This is my javascript code: $( document ).on( "pageinit", "#demo-page", function() { $( document ).on( "swipeleft swiperight", "#demo-page", function( e ) { // We check if there is no open panel on the page because otherwise // a swipe to close the left panel would also open the

e.preventDefault(); behaviour not working in Firefox?

本秂侑毒 提交于 2019-12-04 05:40:22
问题 I have this basic function for handling the key event, everything works great. However, in Firefox 9.0.1 it seems I can't prevent the default event which is showing of bookmarks. Is there any solution to prevent the default behaviour in FF? $(document).keydown(function(evt) { if (evt.which == 66 && evt.ctrlKey) { if (evt.preventDefault) { evt.preventDefault(); } else { evt.returnValue = false; } alert("Ctrl+B pressed"); return false; } }); 回答1: Seems like some sort of bug regarding alert .

If conditions false then prevent default

只愿长相守 提交于 2019-12-04 03:09:53
问题 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) { event.preventDefault(); } }); The link should only work if a is equal to 1 . Is the above code correct. a is set to 1 if a particular condition is met. The link should only work if the condition is met. 回答1: Assuming by ' should only work if a is equal to 1 ' you mean the text

event.preventDefault(); not stopping mousewheel in Firefox

梦想与她 提交于 2019-12-04 03:07:21
问题 I am using the mousewheel in jquery to increase the number of a div, the number increases correctly but the scroll is not stopped in Firefox. $(document).ready(function(){ $('#test').bind('mousewheel DOMMouseScroll', function(event){ var currentValue = parseInt($('#test').text(),10), newValue = currentValue + 1; $('#test').text(newValue); event.preventDefault(); }); }); Fiddle: http://jsfiddle.net/rHVUn/ The fiddle uses the standard mousewheel detection, but I have also used Brandon Aaron's

how prevent submit on press enter in twitter bootstrap typeahead plugin

穿精又带淫゛_ 提交于 2019-12-03 16:16:19
问题 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? 回答1: You can target that specific input by adding an ID to it and simply removing the keydown event for enter like so: JS $(document).ready(function() { $('form input').keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); }); 回答2: The first answer didn

Keep Twitter Bootstrap Tooltip open on mouseleave

故事扮演 提交于 2019-12-03 11:38:14
问题 For a particular case and element I need to show Bootstrap Tooltip by default (once the page is loaded) an always keep it open (even on mouseover and mouseout). That's the code I use to open tooltip by default on the element: $('#myelement').tooltip('show'); Now I'm not sure how to prevent/disable the default action of tooltip on mouseover & mouseout. Any idea? Thanks in advance! 回答1: Solution found. Manual Trigger does the trick - here is the updated code: $('.taskTooltip').tooltip({trigger:

Use of getPreventDefault() is deprecated. Use defaultPrevented instead. Why I'm getting this error and what's the solution for it?

≡放荡痞女 提交于 2019-12-03 10:31:25
Previously I was using jQuery 1.7.1 in my code. I was getting the above error. Then I used the jQuery 1.11.1 straight from the google repository <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js"> </script> but still I'm getting this error. How should I resolve this? Due to this error my other jQuery functionality is also not working. I researched a lot about the solution but every time I got the same solution of upgrading the jQuery version. But this is also not working for me. Try: event.originalEvent.defaultPrevented As in: $(document).on('click', function (e) { if (e

I'm having trouble using the event.preventDefault(); for an ahref on my DOM

白昼怎懂夜的黑 提交于 2019-12-03 07:35:22
I'm having trouble using the event.preventDefault(); for an ahref on my DOM. How do you prevent the url from posting a nofollow delete, as specified by the HTML using JQuery? <td class="trash_can"> <a rel="nofollow" data-remote="true" data-method="delete" data-confirm="Are you sure you want to delete Greek Theater at U.C. Berkeley?" href="/promotions/2/places/46"> <img id="trash_can" src="http://test.dev/images/trash.png?1305741883" alt="Trash"> The following code should subvert the HTML but the HTML posts a delete action, prior to giving a "are you sure" warning. nothing is not working: $

how prevent submit on press enter in twitter bootstrap typeahead plugin

这一生的挚爱 提交于 2019-12-03 06:21:55
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? You can target that specific input by adding an ID to it and simply removing the keydown event for enter like so: JS $(document).ready(function() { $('form input').keydown(function(event){ if(event.keyCode == 13) { event.preventDefault(); return false; } }); }); The first answer didn't worked for me, maybe because of updating the typeahead plugin, but I did passed the problem by using the

Keep Twitter Bootstrap Tooltip open on mouseleave

百般思念 提交于 2019-12-03 03:00:57
For a particular case and element I need to show Bootstrap Tooltip by default (once the page is loaded) an always keep it open (even on mouseover and mouseout). That's the code I use to open tooltip by default on the element: $('#myelement').tooltip('show'); Now I'm not sure how to prevent/disable the default action of tooltip on mouseover & mouseout. Any idea? Thanks in advance! Solution found. Manual Trigger does the trick - here is the updated code: $('.taskTooltip').tooltip({trigger: 'manual'}).tooltip('show'); Use unbind() after show : it will remove all event handler and thus the tooltip