Side navigation
#14761 closed bug (notabug)
Opened February 06, 2014 02:06AM UTC
Closed February 06, 2014 01:11PM UTC
.click() event does not work correctly in Firefox
Reported by: | Redsandro | Owned by: | Redsandro |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.11.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
On a selected virtual anchor element, .click() fires a click event in Chromium. This is correct.
In Firefox however, it does not. You need to manually create a ''click'' mouseEvent.
I've created this ''jsfiddle'' to explain exactly what I mean:
Attachments (0)
Change History (5)
Changed February 06, 2014 02:08AM UTC by comment:1
Changed February 06, 2014 02:21AM UTC by comment:2
owner: | → Redsandro |
---|---|
status: | new → pending |
It works if you append to the body: http://jsfiddle.net/D572L/2/
Is there a reason to not append the link to the body? In general, detached DOM often has issues.
Changed February 06, 2014 10:09AM UTC by comment:3
In the fiddle you don't even use jQuery!
In this line
$(anchor)[0].click();
you access the native element via [0] and try to trigger the native click event.
Changed February 06, 2014 01:06PM UTC by comment:4
_comment0: | '''@dmethvin''' ''Is there a reason to not append the link to the body?'' \ \ Just want to offer some client side text as a download. There is no semantic purpose for the anchor in the Document/DOM. This seems like logical thing to do. I don't need to end up with a bunch of irrelevant elements in my DOM like empty soda cans polluting the street. \ \ '''@anonymous''' '''$(anchor).click();''' doesn't work either. → 1391692110453428 |
---|---|
status: | pending → new |
@dmethvin ''Is there a reason to not append the link to the body?''
Just want to offer some client side text as a download. There is no semantic purpose for the anchor in the Document/DOM. This seems like logical thing to do. I don't need to end up with a bunch of irrelevant elements in my DOM like empty soda cans polluting the street.
Either way, thanks for the workaround. I guess it's human nature to leave trash behind. ;) But still, I think that jQuery should be able to handle this in the way I proposed.
@anonymous $(anchor).click(); doesn't work either.
Changed February 06, 2014 01:11PM UTC by comment:5
resolution: | → notabug |
---|---|
status: | new → closed |
Regardless, this isn't a jQuery bug. This is how the browser behaves.
(I was meaning to file this under Events but I cannot seem to edit that.)