preventdefault

how to get the element on which taphold is fired(jquery mobile)

三世轮回 提交于 2019-12-12 03:18:18
问题 Can you please help me to locate on which element "taphold" is fired by using js, jquery or jq mobile. my html structure is like mentioned below <script> $(document).on("pagecreate", function () { $("#myFilesListView").bind('contextmenu', function (event) { event.preventDefault(); event.stopPropagation(); return false; }); }); $(document).ready(function () { $("#myFilesListView").bind("taphold", function (event) { event.preventDefault(false); event.stopPropagation(); var ID = $(this).child()

why if statement with e.preventDefault ? - drag and drop javascript

梦想与她 提交于 2019-12-12 02:27:12
问题 I'm following this example to make a javascript html5 DnD (drag and drop): http://www.html5rocks.com/en/tutorials/dnd/basics/ To prevent the default behavior for some browsers the default event is prevented. I understand the need. But why is there also an if statement? function handleDragOver(e) { if (e.preventDefault) { e.preventDefault(); // Necessary. Allows us to drop. } // Why this if statement?, To me it seems double: if it is already there (if true), do it again...? Thanks for anyone

jquery javascript avoid running function on condition

早过忘川 提交于 2019-12-11 18:26:56
问题 I've a set of jquery and generally javascript function in a js. Now I want to avoid some of the functions to be available on some condition. For example: function test () { alert("hi"); } function avoid () { if(condition) { //here avoid to call test } } Thanks 回答1: If you want to remove a function without errors (provided the caller of the function doesn't expect a returned result), you might do function avoid () { if(condition) { test = function(){}; // does nothing } } Note that if your

Removing event.preventDefault on click doesn't work

回眸只為那壹抹淺笑 提交于 2019-12-11 17:27:32
问题 I have this code which prevents default behavior on all elements: $('body *').click(function(e){ e.stopPropagation(); e.preventDefault(); }); Now I would like to programmatically click a certain link in the page but first I have to remove the e.preventDefault(); so I used unbind : $('a')[0].unbind('click'); $('a')[0].click(); This doesn't work for me. What am I doing wrong? 回答1: You can't do $('a')[0].unbind('click') use .eq() to get the first element and then unbind .eq(0).unbind('click') 来源

Unable to preventDefault inside passive event listener due to target being treated as passive? Why this error upon scrolling?

♀尐吖头ヾ 提交于 2019-12-11 17:19:45
问题 I am using chrome latest version. My application throws error: Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312 It hinders it ability to properly scroll i.e. jerky scroll. I tried many solutions on the internet but it couldn't solve it. Please help me on this. I am using css3, bootstrap and html. I tried to add passive attribute etc but seems like nothing is working. My code: <!DOCTYPE

Form Field Validation- JavaScript- Empty field

不打扰是莪最后的温柔 提交于 2019-12-11 14:52:00
问题 I am new to JavaScript and I have written the code below, which is supposed to be taking the input of a form field (in that case of the lastname) and in case it is empty, it will not allow me to be redirected to next page. However, it doesnt work.. Does anybody know why or how I could fix it? Thank you in advance! window.addEventListener("DOMContentLoaded", init, false); function init() { var form = document.querySelector("form"); form.addEventListener("submit", function(e) { validate(e); e

Unable to preventDefault inside passive event listener - Swipebox Mobie

孤街浪徒 提交于 2019-12-11 05:30:57
问题 I'm using Swipebox : http://brutaldesign.github.io/swipebox/ I know that I can open a content with swipebox slide like that // Link to click <a href="#mydiv" class="my-swipebox">Click to show</a> // And the div in html <div id="#mydiv">Click <a href="http://example.com">Here</div> The problem is I can't click the link inside this div when it opened by swipebox on mobie (on desktop it working very fine) The chrome browser show this log : [Intervention] Unable to preventDefault inside passive

Programmatically change first page jQuery Mobile shows

人盡茶涼 提交于 2019-12-10 20:11:05
问题 My goal is to show a different first page depending on whether the user is logged in or not. The login check happens using a synchronous Ajax call, the outcome of which decides whether to show a login dialog or the first user page. The normal way to do this would be to set $.mobile.autoInitialize = false and then later on initialize programmatically, as described in the answer to this question. For some reason this won't work, instead another page gets loaded every single time. I decided to

jquery form submit() not working inside callback function after preventing normal submit while using impromptu

大城市里の小女人 提交于 2019-12-10 18:07:18
问题 I am displaying a password prompt instead of submitting the form when user clicks the submit button of a form. I want the form to submit when the user clicks the "Ok" button of the prompt. I am using jquery impromptu plugin (tried both with Version 3.1 and 4.0.1). I am in a hurry abd not getting what is wrong with my code or am I missing something completely. Here is my code - Trial 1 HTML part <form name="frmAddAdnetworkTemplate" id="frmAddAdnetworkTemplate" action="someAction"> ... ...

Prevent enter key from triggering button

放肆的年华 提交于 2019-12-10 17:17:18
问题 I have a search input box which when a user presses enter needs to do nothing. I am using EmberJS and Jquery with the below code. Currently it works to disable a pop up from being triggered but for some reason in IE9 when enter is pressed a toggle button becomes in focus. Works fine in Chrome. I've tried tabindex and preventDefault but neither do the trick. if ($el.hasClass('form-control')) { if ( e.which == 13) { this.get('controller').flipit(); } } Thank you. EDIT------ Here is a snippet of