dcsimg
DOM ELEMENTS IN AJAX REQUEST
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   tom_bell
Posted On:   Thursday, January 11, 2007 08:35 AM

I have a page in development that allows the user to click on an image then the image is updated with an icon placed where they clicked. I can get the coordinates of my click event with the code below but, I get them one click late. After the page loads, the first click returns “id=”. The browser address bar appears to be current i.e. it shows the proper coordinates as a hash. The next click returns “id=123,456” where the numbers are the coordinates of the first click. So, the id is always one click out of phase with the user. An inattentive user will no doubt double post icons unless I can get the click event in phase. As you can see below, I am using document.location.hash to get the coordinates. Other coordina   More>>


I have a page in development that allows the user to click on an image then the image is updated with an icon placed where they clicked.



I can get the coordinates of my click event with the code below but, I get them one click late. After the page loads, the first click returns “id=”. The browser address bar appears to be current i.e. it shows the proper coordinates as a hash. The next click returns “id=123,456” where the numbers are the coordinates of the first click. So, the id is always one click out of phase with the user. An inattentive user will no doubt double post icons unless I can get the click event in phase.


As you can see below, I am using document.location.hash to get the coordinates. Other coordinate methods like clientX, offsetX etc are relative to the window, not the image or don't work in all browsers.



			
				
href="#" onclick="new Ajax.Updater('drill_map', '/map_page/add_hole?id=' + window.location.hash.substring(2), {asynchronous:true, evalScripts:true, onComplete:function(request){new Effect.Appear('drill_map')}}); return false;">
   <<Less
About | Sitemap | Contact