jquery-events

jQuery more than once function called

让人想犯罪 __ 提交于 2019-12-12 02:55:14
问题 I am creating an mobile app and I am calling the function getItem passing data-trnote val. function getTitles() { $(document).ready(function(e){ var list = $('#recent'), items = []; $.mobile.notesdb.transaction(function(t) { t.executeSql('SELECT buildingcode, buildingaddress FROM buildings ORDER BY buildingaddress ASC', [], function(t, result) { var i, len = result.rows.length, row; if (len > 0 ) { for (i = 0; i < len; i += 1) { row = result.rows.item(i); items.push('<li><a href="#display"

Why I can not get the correct value of my <select> field?

此生再无相见时 提交于 2019-12-11 18:08:00
问题 In my index.html , I have a selection drop down menu: <select id="car"> <option value="bmw">BMW</option> <option value="toyota">TOYOTA</option> </select> My js: var c = $('#car'); var selection; c.change(function(){ if(c.val()==='bmw'){ selection = 'BMW'; }else if(c.val()==='toyota'){ selection = 'TOYOTA'; } }); console.log(c.val()); console.log(selection); When page firstly loaded, the initial selection is BMW , and I got console output " BMW " which is fine, then I select " TOYOTA ", but

Jquery + up to date hash change listener?

筅森魡賤 提交于 2019-12-11 15:35:46
问题 I'm using http://benalman.com/projects/jquery-hashchange-plugin/ to listen for hash changes in my project, but his plugin is outdated and does not work with newer versions of browsers such as Firefox 9 and IE9. Searched on Google and here but could not find any other plugin. Or is it enough to just use this code to target most of the browsers? $(window).bind('hashchange', function() { //code }); EDIT: Seems like there was a problem regarding console.log() on these browsers and had nothing to

jQueryMobile and toggling DIV visibility

雨燕双飞 提交于 2019-12-11 14:21:45
问题 I've got strange behaviour and I can't realize how to fix it. I've got mobile version of web service and on every page I'm placing search form in DIV element, whole container should be toggled with common jQuery's .toggle() The code is (script is placed directly in page's code, like in the sample): <div id="search-area" style="display: none"> search form here... </div> <a href="#" id="search-area-switch" data-role="button">Search</a> <script type="text/javascript"> $('#search-area-switch')

“$(document).on” not triggering after event.stopPropagation and “$(a).on” not triggering for new elements

大兔子大兔子 提交于 2019-12-11 12:48:20
问题 I'm trying to write a chrome extension (for casperjs testing). A part of the extension needs to bind to the click event which I'm doing like this: $(document).on('click', 'a', null, handler) This works great for all links, including any newly created elements. Problem is if a link has it's own click handler that calls the event.stopPropagation() method then the .on does not trigger the handler. The workaround is I bind to the a elements like this: $('a').on('click', null, null, handler) This

Cross browser event handling and jquery support

梦想的初衷 提交于 2019-12-11 08:06:16
问题 Just read of ppk's web site that IE's mechanism of registering events does not set the this object to the actual element that was clicked. Instead it refers to the global window object. The below is quoted from his site: But when you use the Microsoft event registration model the this keyword doesn’t refer to the HTML element. Combined with the lack of a currentTarget–like property in the Microsoft model, this means that if you do element1.attachEvent('onclick',doSomething) element2

Detect whenever Boostrap carousel cycles automatically

匆匆过客 提交于 2019-12-11 02:07:49
问题 I am trying to detect whenever the bootstrap carousel is sliding automatically but I can't find anyway of doing so... No info on the slid.bs.carousel that tells if the user triggered the event or if it was triggered by the automatic scroll (bootstrap sliding intervals). One way I tried to solve this was by detecting if the bootstrap slid.bs.carousel event was triggered by a user's interaction by binding a function who adds a propriety and it's value to the event once the user triggers it and

The best way to add eventlistener to an element

只谈情不闲聊 提交于 2019-12-10 19:31:46
问题 I'm trying to find the most productive way to hanging event. Lets imagine we have this structure: <ul> <li> 1st li </li> ... <li> 99999th li </li> <ul> So, we have about 10000 li elements and we want to add event listener to all this elements, lets say we can use jQuery too. First thought <li onclick="console.log(this)" >...</li> bad part of this solution - we have increase a size of html markup because always repeating onlick. Second thought $('ul li').on('click', function(){ console.log

JQuery - Android - The 'Keyup' Event Does Not Work On Backspace In Chrome

心已入冬 提交于 2019-12-10 17:15:17
问题 I am wondering why the backspace/ delete button does not detect a keyup event in jQuery. I find this odd as it is useful and should be supported. Are there any alternatives to this? This is only happening in Android - Chrome. 回答1: You can actually fix this by attaching an event listener to the input. var inputBox = document.getElementById('inputId'); inputBox.addEventListener(‘input’, function() { exampleFunc(); }, false); Cheers 来源: https://stackoverflow.com/questions/24557402/jquery-android

Mobile Safari and jQuery events, nothing is firing?

感情迁移 提交于 2019-12-10 14:53:21
问题 I have an app written in HTML5/JavaScript for an in-dash car unit. It is a 'single-page' app with fragments loaded into divs on the main page in response to different events. I've been asked to port it to the browser so that it can be used for marketing, presentations, whatever. This didn't seem like a big deal since there was very little to adapt, just needed to adjust some CSS so that it could be displayed the same across all browsers. Then, they decided that the device they wanted to run