javascript-events

Google Autocomplete Places API not triggering event on change via TAB

时间秒杀一切 提交于 2020-01-28 05:26:06
问题 Per the Google Autocomplete Places API documentation, the getPlace() call should return a Places object with all the location data, or, if that place doesn't exist (i.e. - the user ignored the suggestions), it should return a stub with just the name element of the Places object filled in. However, it only does this latter operation when the user hits ENTER, not if they TAB out of the field. I've tried looking at the change event, the keyup, keydown events. I've tried triggering a keydown

jQuery: How to detect if popup window is closed?

这一生的挚爱 提交于 2020-01-25 23:13:11
问题 I want to detect if the user pressed the browser's close button on a popup window in my application. By searching around I found this solution: $(window).bind('beforeunload', function(event) { $.ajax({url:"acquisition_cleanup.php", async:false}); var dataStr = 'id={id}'; $.ajax({ type: "POST", url: "acquisition_cleanup.php", data: dataStr, success: function() { window.close(); } }); }); It works well on my Ubuntu machine with Firefox 31. But unfortunatly it does not work on windows machine

jQuery: How to detect if popup window is closed?

末鹿安然 提交于 2020-01-25 23:13:11
问题 I want to detect if the user pressed the browser's close button on a popup window in my application. By searching around I found this solution: $(window).bind('beforeunload', function(event) { $.ajax({url:"acquisition_cleanup.php", async:false}); var dataStr = 'id={id}'; $.ajax({ type: "POST", url: "acquisition_cleanup.php", data: dataStr, success: function() { window.close(); } }); }); It works well on my Ubuntu machine with Firefox 31. But unfortunatly it does not work on windows machine

railscast 197 how to: function add_fields

廉价感情. 提交于 2020-01-25 12:34:30
问题 I am following the railscast 197 but Im using rails 3.1.3,jquery and scaffold, no nifty:scaffold,everything works fine but I can't add fields, in that episode Ryan Bates give the code for jquery, but is not working for me, here is my code...thanks in advance. in javascript/application.js function remove_fields(link) { $(link).prev("input[type=hidden]").val("1"); $(link).closest(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp

Body OnClick doesn't work… but the onclick works when attached to a <a> tag?

醉酒当歌 提交于 2020-01-25 12:34:11
问题 I have the following Onclick event onClick="document.body.style.background = 'url(galleries/g2.jpg)'" and when i attach it to <a onClick="document.body.style.background = 'url(galleries/g2.jpg)'"> blah</a> all works fine. but I want it as a body onclick event as follows <body class="g" onClick="document.body.style.background = 'url(galleries/g2.jpg)'"> and i get no dice. The only thing to note would be that the class "g" already has a background image specified, but I don't think that should

Body OnClick doesn't work… but the onclick works when attached to a <a> tag?

℡╲_俬逩灬. 提交于 2020-01-25 12:33:25
问题 I have the following Onclick event onClick="document.body.style.background = 'url(galleries/g2.jpg)'" and when i attach it to <a onClick="document.body.style.background = 'url(galleries/g2.jpg)'"> blah</a> all works fine. but I want it as a body onclick event as follows <body class="g" onClick="document.body.style.background = 'url(galleries/g2.jpg)'"> and i get no dice. The only thing to note would be that the class "g" already has a background image specified, but I don't think that should

railscast 197 how to: function add_fields

社会主义新天地 提交于 2020-01-25 12:33:12
问题 I am following the railscast 197 but Im using rails 3.1.3,jquery and scaffold, no nifty:scaffold,everything works fine but I can't add fields, in that episode Ryan Bates give the code for jquery, but is not working for me, here is my code...thanks in advance. in javascript/application.js function remove_fields(link) { $(link).prev("input[type=hidden]").val("1"); $(link).closest(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp

Javascript Universal way to know added new element

时光总嘲笑我的痴心妄想 提交于 2020-01-24 21:37:25
问题 AddEventHandler in Javascript is for handling the events (like onclick) universally (i.e. on any element). Is there a way to fire an event (don't know which kind) when a new element (i.e input, div, select, etc.) is being added to the page (through Ajax, jQuery, etc.)? I've looked into the DOM documentation on dev mozilla but couldn't find anything. May be I'm not looking in the right pages. 回答1: Is there a reason you want to know? If the reason is you want to add event handlers to new

onFocus and onBlur

空扰寡人 提交于 2020-01-24 17:56:26
问题 For some reason the onblur and onfocus properties don't work. Am I defining them right? var replyTxt = document.createElement("input"); replyTxt.id="replyTxt"; replyTxt.type="text"; replyTxt.value="Write a reply"; replyTxt.onfocus = function(){if(replyTxt.value==replyTxt.defaultValue) replyTxt.value='';}; replyTxt.onblur= function(){if(replyTxt.value=='') replyTxt.value=replyTxt.defaultValue;}; I have also tried putting "function(){if(replyTxt.value==replyTxt.defaultValue) replyTxt.value='';}

Set value to input field onchange from other input field

寵の児 提交于 2020-01-24 13:37:52
问题 I'm completely new to javascript, and currently I'm trying to set a value to an input field triggered by an onchange event from another input field. Code sample - input field 1: <input type='text' onchange='methodThatReturnsSomeValue()'> Now I want to assign the following input field's value with the returned one from the method triggered from onchange above: <input type='text'> Does anyone know how this can be solved? 回答1: Simply assign an identifier to each input, and pass the input to the