开发者

JavaScript JQuery trigger("click") problems

开发者 https://www.devze.com 2023-01-23 19:37 出处:网络
I have a form split up into two parts. One part is for entering data and the following part is a list of the entered data. When I CUD an object in the form I want to update the list, I do this via a t

I have a form split up into two parts. One part is for entering data and the following part is a list of the entered data. When I CUD an object in the form I want to update the list, I do this via a trigger:

jQuery("#magnifier").parent().trigger("click");

Due to the heavy use of Safari in my company I had to choose the parent otherwise safar开发者_如何学JAVAi wouldn't accept the trigger. The following code is generated by rails (V 1.2.3) and kicks off the update of my list:

<a href="#" onclick="new Ajax.Updater('list_section', '/input_form/reload_list',
{asynchronous:true, evalScripts:true, parameters:Form.serialize('periode_form')}); return false;">
  <img alt="Magnifier" border="0" id="magnifier" src="/images/magnifier.png?1288947266">
</a>

Problem is in my company Safari and Opera are the most used browsers. I can get it to work for one browser but not for the other. Is there a way how I can implement this without a if opera else kind of yacki code?


I'm going to assume you have a form on the page. Based on the contents of the form, you want a list updated elsewhere. This is pretty easy to do and should not require any goofy opera checks. My check obviously doesn't have any AJAX, so you will have to fill in the blanks there.

http://jsfiddle.net/Q7u7f/

0

精彩评论

暂无评论...
验证码 换一张
取 消