I am working with jQuery, I am trying to add a click trigger inside the click function for a different link. Heres what I have:
$('.details .banner .banner_link').on("click", function(e){
e.stopPropagation();
e.preventDefault();
$('a.banner_link').trigger("click");
});
As you can see, I am using stopProp and PreventDef, but I am still getting:
Uncaught RangeError: Maximum call stack size exceeded
This is driving me crazy, Ive been stuck on this for a while any help please, or at least why this is happening?!
Background:
.banner_link and a.banner_link in the code above are two separate links on the same page. I took the html for the a.banner_link and added it (via js) onto the page to show the same link in a separate location.
I want to emulate the behavior of the original link in the newly created link(it causes a modal to pop up), therefore I am doing this with the trigger("click") function.
Note:
If I just run the trigger('click') outside the scope of the outer click function, it runs fine!
.banner_linkelement is clicked, click alla.banner_linkelements." This seems like like pretty straightforward infinite recursion. Maybe your misunderstanding is rooted in the statement ".banner_linkanda.banner_link... are two separate links on the same page" -- the selector.banner_linkapplies to all elements with the classbanner_link. Why do you think those wouldn't be included in the elements described by the selectora.banner_link? - apsillers.banner_linkwhich triggers a click event on.banner_linkso its on an indefinite loop until it gets stopped by your browser. - ODelibalta