jquery-events

swipeleft/swiperight triggered during vertical scroll in jQuery mobile

萝らか妹 提交于 2019-12-03 12:45:12
Problem is that swipeleft/swiperight event is trigger when I want vertical scroll. We are using jQuery mobile 1.1.0 version and jQuery 1.7.1. and code is: $(document).delegate('#quizResumePage', 'swipeleft swiperight', function (event) { event.stopImmediatePropagation(); if (event.type == 'swipeleft') { $('#btnnext').trigger('click'); } else if (event.type == 'swiperight') { $('#btnprevious').trigger('click'); } event.preventDefault(); }); Then why swipe event trigger when I want to scroll the page? This problem is occur in the Samsung galaxy android 2.3.5... Can any one help me for this issue

DOM Events API: event delegation and stopPropagation

安稳与你 提交于 2019-12-03 09:09:48
This is a code with jQuery 1.7: <div class="test"> <div class="bu"> <a> bu here </a> </div> </div> <script src="http://code.jquery.com/jquery-1.7.js"></script> <script> $(document).on('click', '.test', function () { alert(0); return false; }); $(document).on('click', '.bu', function () { alert(1); return false; }); $(document).on('click', '.bu', function () { alert(2); return false; }); </script> Xlicking on .test > .bu will alert "1" and alert "2", but not alerts "0" My question is: how to do the same WITHOUT jQuery (on native DOM API)? Seems, I can't do it with Native DOM API without

Using jQuery to listen to keydown event

情到浓时终转凉″ 提交于 2019-12-03 04:06:38
问题 I want to detect when the enter key is pressed, on HTML that will be injected dynamically. To simply detect when the enter key is pressed, I can do: $('#textfield').keydown(function (e){ if(e.keyCode == 13){ console.log('Enter was pressed'); } }) This code works for on() , but I am worried it is inefficient since jQuery will check every time a key is pressed. Is there anything inefficient about this? $('body').on('keydown','#textfield', function(event) { if (event.keyCode == 13) { console.log

Click event is not working

[亡魂溺海] 提交于 2019-12-02 08:38:32
I have one problem with my code. The one click event doesn't work after another one. My ajax and jquery code is as below: <!-- Ovdje izbacujemo modal za potvrdu kad se klikne na gevonden i onda ako je kliknuto na potvrdi odradi se update baze sa ajaxom --> <script type="text/javascript"> $(document).ready(function() { $(document).on("click","button[class*=btnFound]", function(e){ var cijeliID = this.id.split("-"); var id = cijeliID[1]; $($("#confirmBox-"+id).data("target")).fadeIn(400); e.preventDefault(); }); }); </script> <script type="text/javascript"> $(document).ready(function() { $

Restricting keyboard input with keypress jQuery

旧时模样 提交于 2019-12-02 04:57:14
I have a keypress function I created with a game to take user input in a form with the enter button (and to have a series of functions I defined first go in sequence on the Enter key being pressed). $(".form-control").keypress(function(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == 13) { var space = $(this).val().toLowerCase(); if (!(wrongGuesses.indexOf(space) > -1 || rightGuesses.indexOf(space) > -1)) { play(space); $(this).val(''); endGame(); return false; } else window.alert("You already guessed this letter."); } }); which works great. But, Now, I'm

How to include submit button name and values on form Serialize() ajax

我与影子孤独终老i 提交于 2019-12-02 03:44:21
问题 I have trouble, my code doesn't work, because my server script side need a name from the submit button. I'm using Ajax method, and I'm using data: serialize, when I have Click on Submit, it doesn't work. Here is my JavaScript code: $(function(){ $('#buy_product').submit(function(e){ e.preventDefault(); var submitData = $('#buy_product').serialize(); submitData.push({ name: this.name, value: this.value }); $('.loading').html('{{HTML::image('img/ajax-loader.gif')}}'); $.ajax({ type: "POST",

Loading spinner gif image gets stuck

我的未来我决定 提交于 2019-12-02 02:02:09
I have a 6kb animated gif loading spinner. when I open it in a browser window, it spins fine. But when it opens on an ajax call on my web page, it is stuck. It appears ontime and disappears ontime, but does not spin. Any ideas? Here is the jQuery code: $('#please-wait') .css("visibility", "visible")//.hide() .ajaxStart(function() { $(this).css("visibility", "visible"); }) .ajaxStop(function() { $(this).css("visibility", "hidden"); }); or $('#please-wait') .show() .ajaxStart(function() { $(this).show(); }) .ajaxStop(function() { $(this).hide(); }); any ideas? Here is a jsfiddle example of how

jQuery events: prepend a callback handler to already existing ones

删除回忆录丶 提交于 2019-12-01 23:27:50
问题 On a web page are elements with click and/or keypress handlers. If I add a new one it would be executed after them. I need a way to add a new callback which is prepended to the event handler list, so that it is executed beforehand. How is that possible with jQuery? Update Why can't I just use jQuery's unbind method? I am injecting my jQuery code to any web page, so that i don't know if any and which JavaScript framework is used. I need a universal way to detect event handlers and prepend mine

jQuery events: prepend a callback handler to already existing ones

£可爱£侵袭症+ 提交于 2019-12-01 20:31:01
On a web page are elements with click and/or keypress handlers. If I add a new one it would be executed after them. I need a way to add a new callback which is prepended to the event handler list, so that it is executed beforehand. How is that possible with jQuery? Update Why can't I just use jQuery's unbind method? I am injecting my jQuery code to any web page, so that i don't know if any and which JavaScript framework is used. I need a universal way to detect event handlers and prepend mine. (Before you ask, I'm building a "recorder" application that tracks the users actions to store them

How to monitor when the body 'data' attribute changes in jQuery?

泪湿孤枕 提交于 2019-12-01 20:30:34
问题 I have data-segment attribute in my body tag that is changed by a slider. I need to trigger a function based on the value of this, when it is changed. I'm not sure how to attach an event listener in this case though? 回答1: `There is no reliable cross-browser way to receive an event when a DOM node attribute is changed. Some browsers support "DOM mutation events", but you shouldn't rely on them, and you may Google that phrase to learn about the ill-fated history of that technology. If the