javascript-events

Firing an event when the caret gets within a particular div/span/a tag and also, when the caret leaves the tag

这一生的挚爱 提交于 2020-01-05 07:23:13
问题 The idea is this - There is a contenteditable element with some text in it. Am trying to build out a tagging mechanism (kind of like twitter's people tagging when you type '@'). Whenever a user types '@', it shows up a popover with suggestions and filters when they continue typing. Until here it's easy and I have got it figured out. The problem comes when I need to show the popover if/only if the caret is over the element containing the tag. <div contenteditable=""> <p>Some random text before

Jquery Chosen - Prevents capture of keypress

。_饼干妹妹 提交于 2020-01-05 07:16:11
问题 I have a div (id = div_search_fields) within which I have several jQuery Chosen dropdowns. Attached to the div I have a keypress capture listener which, if the key pressed is the Enter key, submits the selected stuff by clicking a hidden submit button. $("#div_search_fields").keypress(function(e) { if (e.which == 13) { $("#hiddenSubmitButton").click(); } }); For some reason this listener is never called if I have just selected an option in one of the chosen dropdowns. Within the "div_search

Jquery Chosen - Prevents capture of keypress

好久不见. 提交于 2020-01-05 07:16:02
问题 I have a div (id = div_search_fields) within which I have several jQuery Chosen dropdowns. Attached to the div I have a keypress capture listener which, if the key pressed is the Enter key, submits the selected stuff by clicking a hidden submit button. $("#div_search_fields").keypress(function(e) { if (e.which == 13) { $("#hiddenSubmitButton").click(); } }); For some reason this listener is never called if I have just selected an option in one of the chosen dropdowns. Within the "div_search

how to disable auto </br> after <td> in CKEditor?

Deadly 提交于 2020-01-05 05:50:09
问题 CKEditor will add <br> after <td> .. how to disable this or turn off this function? Before : <td> <img style="width: 950px; height: 114px;" src="http://www.abc.com/uploads/image/Newsletter/Newsletter2.jpg" alt=""> </td> After Save : <td> <br> <img style="width: 950px; height: 114px;" src="http://www.abc.com/uploads/image/Newsletter/Newsletter2.jpg" alt=""> </td> My setting : CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config

touchstart in JavaScript no longer returns TouchList

纵然是瞬间 提交于 2020-01-04 23:21:59
问题 I ran into a very strange problem. I am binding the touchstart event to an element, and would like to retrieve the X and Y co-ordinates of the event. All documentation online indicates that this is available through one of the following: e.touches e.targetTouches e.changedTouches However, the following code, called on #test returns undefined for all three supposed arrays when running this from jQuery: $('#test').bind('touchstart', function(e) { alert(e.targetTouches); alert(e.touches); alert

touchstart in JavaScript no longer returns TouchList

笑着哭i 提交于 2020-01-04 23:20:52
问题 I ran into a very strange problem. I am binding the touchstart event to an element, and would like to retrieve the X and Y co-ordinates of the event. All documentation online indicates that this is available through one of the following: e.touches e.targetTouches e.changedTouches However, the following code, called on #test returns undefined for all three supposed arrays when running this from jQuery: $('#test').bind('touchstart', function(e) { alert(e.targetTouches); alert(e.touches); alert

onsubmit event not working for asynchronous form submit

无人久伴 提交于 2020-01-04 13:46:32
问题 I have created a form using struts tags. I have submitted the form asynchronously using struts jquery's submit tag. Now before i submit my form i want to call a javascript function checkUser() , that checks if there is some client side error And prevents the form from submitting. The form with the javascript function is as follows: <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; var k = document.getElementById("register_userDetails_username").value; var urls = "pass.jsp

addEventListener pass caller as argument

℡╲_俬逩灬. 提交于 2020-01-04 09:18:28
问题 I have the following code. And my problem is that when clicking, the event is firing but the argument passed is not the correct one. It is passing the last dynamically created row i.e. dataStructure.length value. Anyone knows a solution how to get around this? var table = document.getElementById('output'); for(i =0; i<dataStructure.length; i++){ var row = document.createElement('tr'); row.setAttribute('id', i); var url = dataStructure[i].url; if(document.addEventListener) row.addEventListener

Capturing onload event when dynamically loading .js files?

佐手、 提交于 2020-01-04 08:40:39
问题 Is there a capture the on load event when dynamically adding a script tag with JavaScript in IE? The code below works in FireFox and Chrome but not in IE. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> </body> </html> <script type="text/javascript" language="javascript"> var elemScript = document.createElement("script");

Firefox attachEvent and addEventListener issues with both

老子叫甜甜 提交于 2020-01-04 07:54:53
问题 So i've got 2 sets of js one with attach event and one with addEventListener attach event works perfectly in IE 8 as expected and addEventListener for IE 9. if i use addEventListener on firefox in jsfiddle it seems to work fine no issues in firefox but as soon as i deploy it and try to use it as intended it just doesn't work at all any input would be great.. IE 8 var formsCollection = document.getElementsByTagName("form"); var chain = ""; for(var i=0;i<formsCollection.length;i++) { // alert