Link to home
Start Free TrialLog in
Avatar of Ralph
RalphFlag for United States of America

asked on

Trying to simulate a click on a link

I tried:   $("a #RtMgn_DomRatePlan")[0].click() ;, but got VM87:558 Uncaught TypeError: Cannot read property 'click' of undefined.

Also tried:
var a = $("a #RtMgn_DomRatePlan")[0] ;
simulate_link_click(a) ;

with

function simulate_link_click(element)
{ 
  var e = document.createEvent('MouseEvents');
  e.initEvent( 'click', true, true );
  element.dispatchEvent(e);
}

Open in new window

And other options / variations.

Seems links are not jQuery triggerable events, but it can be in the DOM??????

I just want to avoid trying to pull a bunch of data out of the link's data- elements and the coding that led up to a hairy ajax call.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ralph

ASKER

Thanks Kim.  Yes, your last assumption was correct, a link with that tag.

It didn't seem to work, but it turns out that I need to go at it a different way anyway.
The link ultimately would do an ajax to mysql based on what the operator earlier used to navigate to that page, but s/he may have done other form manipulations in between, so I actually need to, (on this cancelling event of some other activity), get the last values stored in hidden fields, not what was used to initially populate the form.

Thanks!