简体   繁体   中英

JavaScript JQuery trigger(“click”) problems

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 safari 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM