Closed
Bug 7997
Opened 26 years ago
Closed 25 years ago
[DOM] can't assign event handler to dom-created nodes from JS
Categories
(Core :: DOM: Events, defect, P3)
Tracking
()
VERIFIED
FIXED
M17
People
(Reporter: alecf, Assigned: joki)
References
Details
Attachments
(1 file)
|
736 bytes,
text/html
|
Details |
This is on Linux, I haven't tried windows yet.
I have code that looks like:
var sel = document.createElementWithNameSpace("SELECT",
"http://www.w3.org/TR/REC-html40");
.
.
sel.onchange = myOnChangeHandler;
.
.
divtag.addChild(sel);
insertionPoint.addChild(divtag)
basically I am:
- creating a new select element
- adding an onchange handler
- adding it to a similarly created DIV tag, then adding that div tag to the DOM
tree)
this doesn't seem to actually install the handler.
If the SELECT element is already in the DOM (i.e. with a <html:select> tag in a
XUL file) then I can add the event handler and it works just fine.
Updated•26 years ago
|
Assignee: vidur → joki
Comment 1•26 years ago
|
||
This one's for you, Tom.
| Assignee | ||
Updated•26 years ago
|
Status: NEW → ASSIGNED
Summary: can't assign "onchange" handler to dom-created <select> from JS → can't assign event handler to dom-created nodes from JS
Target Milestone: M9
| Assignee | ||
Comment 2•26 years ago
|
||
Yeah, this is me. I hadn't caught this case before. Its a more general
problem than your test case actually. Modifying summary and accepting.
Comment 3•26 years ago
|
||
joki at w3c
Comment 4•26 years ago
|
||
Comment 5•26 years ago
|
||
I just added myself to the cc list and I attached another test. This test maybe
a separate bug, Tom you can choose. But I think it is basically demonstrating
the same problem and it appears to be related to bug #12849
Comment 6•26 years ago
|
||
rods, your bug looks like a problem because the OnLoad() handler isn't firing.
If I put <script>Init()</script> in at the bottom, the event handler fires
correctly and stuff. Sounds like a necko problem maybe, try handing it to gagan
to get off joki's cluttered radar.
Updated•26 years ago
|
Assignee: joki → gagan
Status: ASSIGNED → NEW
Comment 7•26 years ago
|
||
Gagan, could you take a look at this?
Updated•26 years ago
|
Assignee: gagan → joki
Comment 8•26 years ago
|
||
rods: you should file another bug (against necko) for your problem, which is
unrelated to alecf's in this bug. Handing this back to joki (sorry for the
noise, Tom).
Moving to M11. Not to hold for M10 per conversation with joki during bug triage
today.
| Assignee | ||
Comment 10•26 years ago
|
||
Moving multiple bugs to m12
Comment 11•26 years ago
|
||
Moving to m13 because Joki seems to be distracted.
| Assignee | ||
Updated•26 years ago
|
Target Milestone: M13 → M14
| Assignee | ||
Comment 12•26 years ago
|
||
Mass-moving excess bugs to M14
Updated•26 years ago
|
Target Milestone: M14 → M17
Comment 13•26 years ago
|
||
Moving M17.
| Assignee | ||
Comment 14•25 years ago
|
||
*** Bug 32400 has been marked as a duplicate of this bug. ***
| Assignee | ||
Comment 15•25 years ago
|
||
Adding [DOM] prefix to bugs related to DOM Level 0, 1, or 2
compatibility/compliance.
Status: NEW → ASSIGNED
Summary: can't assign event handler to dom-created nodes from JS → [DOM] can't assign event handler to dom-created nodes from JS
| Assignee | ||
Comment 16•25 years ago
|
||
In working on this it seems that this is actually working okay already. The
first test case is incomplete but from reconstructing it it the event handler is
being added via
sel.onchange = myOnChangeHandler;
Adding event handlers through function reference like this does indeed seem to
work. We don't currently handle adding event handlers through setAttribute or
innerHTML but that is covered in 33577. I'm going to mark this fixed.
Here is the test case I used for verification.
<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
<SCRIPT>
function click()
{
alert('got click');
}
var button = document.createElement('BUTTON');
button.onclick = click;
button.appendChild(document.createTextNode("click me"));
document.body.appendChild(button);
</SCRIPT>
</HTML>
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Updated•24 years ago
|
Component: DOM Level 1 → DOM Events
Comment 18•24 years ago
|
||
verifying 2001-05-29-09-trunk windows
and 2001-05-31-09-trunk linux
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•