I wrote this part of the code a few years ago, and at that time it worked in FF and Chrome, but now it leads to an endless loop in Chrome.
<script> function clickChildLink(el, event) { console.log('inside function'); var evtTarget = $(event.target); if (evtTarget.is('a')) { console.log('returning'); return; </script> <div onclick="clickChildLink(this, event);"> <a href="#" onclick="console.log('before'); event.stopPropagation(); console.log('after'); return false;">Header</a> </div>
You can run the code here: http://jsfiddle.net/Py7Mu/205/
Basically, what he should do is if the user clicks inside the div (i.e. the title), he finds the link inside it and causes a click on it. In Chrome, this triggered click also propagates back to the parent, who, in turn, starts the whole process again.
I know that I should use less intrusive javascript, but this comes from the old rails application (update hopefully coming soon).
Any idea why the event doesn't actually stop propagating? Technically, the code should work without calling stopPropagation, since the if statement inside the function should stop subsequent calls from firing. Chrome doesn't seem to update currentTarget on click soft call
source share