jquery-events

Handle selected event in twitter bootstrap Typeahead?

我与影子孤独终老i 提交于 2019-12-05 10:12:37
问题 I want to run Javascript function just after user select a value using twitter bootstrap Typeahead . I search about some thing like selected event. 回答1: $('.typeahead').on('typeahead:selected', function(evt, item) { // do what you want with the item here }) 回答2: $('.typeahead').typeahead({ updater: function(item) { // do what you want with the item here return item; } }) 回答3: For an explanation of the way typeahead works for what you want to do here, taking the following code example: HTML

How do I pass javascript events from one element to another?

◇◆丶佛笑我妖孽 提交于 2019-12-05 03:59:26
Setting up the stage: I have 2 layers one on top of the other. The bottom layer contains links (simple images), The top layer contains advanced tooltip like hovers for the bottom layer. These tooltips can be large (they can overlap onto other links easily, and almost always overlap the link they are tooltipping). My question: I'd like my mouseover events to occur on the bottom layer, and then on mouseover display the tooltip in the upper layer. This way as you move off of the bottom link the tooltip in the upper layer goes away, and the tooltip for the new link can show up. How do I take the

How to trigger custom event with jQuery?

一世执手 提交于 2019-12-05 03:08:09
I'm attaching a custom event handler to the body in jQuery's ready method. Afterwards I immediately trigger the custom event but nothing seems to happen. $(function(){ $("body").on("test", function(){ alert("test triggered"); } $("body").trigger("test"); } Firstly you have a syntax error $(function(){ $("body").on("test", function(){ alert("test triggered"); }); < ---- Missing this $("body").trigger("test"); }); Secondly you cannot trigger the event from the console , as $(function() {}); forms a closure and you will not have access to any of the methods inside them For it to work like you are

DOM Events API: event delegation and stopPropagation

倖福魔咒の 提交于 2019-12-04 14:43:04
问题 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

jqueryMobile tap and bubbling/propagation

ぐ巨炮叔叔 提交于 2019-12-04 13:54:55
See this sample in android 2.x browser..its a sample to replicate a scenario in my application.. http://johnchacko.net/samples/tap.html Its about listening to 'tap' and calling changePage from listener... The second page is having some input fields, 'tap' event is bubbling/propagating to second page and focus is randomly set to input fields... I read similar issues and want to know anybody experienced same issue and got a workaround for it.... Or I must use only 'click' ? It can be fixed in few ways: On tap/click event use this methods before you call changePage: e.stopPropagation(); e

Bootstrap Popover works after one click - JavaScript

帅比萌擦擦* 提交于 2019-12-04 09:52:10
I have some Bootstrap-Buttons, which should show a popover when the button is clicked. usernameL.onclick = function(e){ $("#" + e.currentTarget.id).popover({html : true}); } When the website has loaded and I click the button a first time, nothing happens. If I click a second time, the popover opens and it works normal. What can I do for the popover to appear on the first click? In your code, first time you click on button the popover start to init only, so until the second click, you see the effect, I'm not sure about the version popover which you used. As the resource which I have found, they

Any event to detect when the “Class” attribute is changed for a control

被刻印的时光 ゝ 提交于 2019-12-04 06:38:44
问题 I have a "div" control with some id="myDiv" class="myClass" var var1=10; in Javascript. Based on user action I will change the class for this control from "myClass" to "newClass" so when this has happened I want to change the value of var1 to 20. So how would I recognize that change in Class? 回答1: You may use onpropertychange(IE) and DOMAttrModified (others) 回答2: You'll have to use 3 things: onpropertychange event, for IE < 9 DOMAttrModified , works in IE9, Opera, Firefox, and not regrettably

Javascript to Drag and Drop in HTML5

为君一笑 提交于 2019-12-04 05:54:40
Trying to do a simple drag and drop example in HTML5 - but when I drop the image into the div element I get the following error. Uncaught TypeError: Cannot set property 'innerHTML' of null So I assume the error message means dragElement is null. I don't understand why though, because I set it in the dragstart event to be the HTML of the img element. Anyone know how to make this work? var dragElement = null; $('#x').bind('dragstart', function (e) { dragElement = this; e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/html', this.innerHTML); }); $('#drop-box').bind('dragover',

Binding event to chosen select

笑着哭i 提交于 2019-12-03 22:51:40
I have this code for a select box which is being displayed by the Chosen jQuery plugin. What I am trying to achieve is to get the value from the current item that has been selected: <div> <select id="schedule_event" name="schedule[event]" style="display: none; " class="chzn-done"><option value="Game" selected="selected">Game</option> <option value="Event">Event</option> <option value="Training">Training</option> </select> <div id="schedule_event_chzn" class="chzn-container chzn-container-single chzn-container-active" style="width: 854px; "> <a href="javascript:void(0)" class="chzn-single chzn

jQuery event for HTML5 datalist when item is selected or typed input match with item in the list

我怕爱的太早我们不能终老 提交于 2019-12-03 18:49:28
问题 I have datalist like below - <input id="name" list="allNames" /> <datalist id="allNames"> <option value="Adnan1"/> <option value="Faizan2"/> </datalist> What I want is, when an item is typed in completely(for example say in input box when user completely type "Adnan1") or selected from list, then I want an event. I tried couple of approaches but both doesn't help me so far. Approaches are - $("#name").change(function(){ console.log("change"); } problem with this is, the event only gets