Side navigation
#11326 closed bug (invalid)
Opened February 11, 2012 01:00AM UTC
Closed March 14, 2012 08:30AM UTC
Last modified October 12, 2012 09:29PM UTC
Triggering click on anchor target does not follow link
Reported by: | anonymous | Owned by: | anonymous |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Given the markup:
<a href="/somelink"></a>
and the JS:
$('a').click();
the default action is not executed.
On the other hand, given the markup:
<a href="/somelink"><span></span></a>
and the JS:
$('span').click();
the default action of the anchor is executed--the link is followed.
The problem code can be found at line 3158 in 1.7.1--it specifically filters out this case:
(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem )
This is inconsistent and is causing me some pain. Please remove it.
Attachments (0)
Change History (6)
Changed February 14, 2012 09:43AM UTC by comment:1
owner: | → anonymous |
---|---|
priority: | undecided → low |
status: | new → pending |
Changed February 27, 2012 06:01PM UTC by comment:2
_comment0: | I've come across this same problem, and am currently working around it by creating inner spans within my a tags. \ \ reduced test case here \ http://jsfiddle.net/FrKyN/ \ \ the top link has an event handler that issues a .click() on the second link \ notice the user is not sent to the target of the second link \ \ → 1330365898293723 |
---|
I've come across this same problem, and am currently working around it by creating inner spans within my a tags.
reduced test case here
http://jsfiddle.net/bklaas/FrKyN/253/
the top link has an event handler that issues a .click() on the second link
notice the user is not sent to the target of the second link
Changed February 28, 2012 06:28PM UTC by comment:3
This behavior of .trigger()
is from #873 introduced in version 1.2 (September 2007) and provides consistent cross-browser results. Only Internet Explorer has a DOM .click()
method, but other browsers do not.
http://jsfiddle.net/dmethvin/v7LKF/ Link only
http://jsfiddle.net/dmethvin/v7LKF/1/ Span in a link
Note that your event handler can do something simple like document.location.href = this.href
if you want to follow the link in all browsers.
bklaas, your test case did not come through. I would be interested in seeing it.
Changed March 14, 2012 08:30AM UTC by comment:4
resolution: | → invalid |
---|---|
status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
Changed October 11, 2012 04:39PM UTC by comment:5
i think that line of code should be removed too, refer:
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.