#5938 closed enhancement (fixed)
There is no way to disconnect connections created via NodeList.connect()
Reported by: | mrblakwell | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | Query | Version: | 1.0 |
Keywords: | Cc: | ptwobrussel | |
Blocked By: | Blocking: |
Description (last modified by )
if I connect an event to a bunch of nodes:
var foo = dojo.query(QUERY).connect("onchange",function(){/* .... */})
there is nothing in foo that allows me to disconnect these events. there are workarounds (see below) but nothing quick and easy.
from the #dojo IRC channel:
[14:56] mrblakwell: how do I disconnect events added via dojo.query(QUERY).connect("onchange",function(){do stuff})
[14:58] slightlyoff: mrblakwell: you don't =
[14:58] mrblakwell: sweet
[14:58] slightlyoff: mrblakwell: so I've been thinking about it
[14:58] slightlyoff: mrblakwell: and I keep thinking that connect could add a this.handles()
[14:59] slightlyoff: so you could get/keep a list of the handles that any connect() creates
[14:59] slightlyoff: which you'd then pass to something like NodeList?.disconnect(handles)
[15:00] slightlyoff: mrblakwell: if you file the bug I'll take it = )
following that, ptwobrussel suggested this as a workaround:
var handles =
dojo.query("a").map(function(x) {
return dojo.connect(x, "onclick",
function(evt) { /* ... */ });
});
/* Sometime later... */ dojo.forEach(handles, function(x) {
dojo.disconnect(x);
});
Change History (10)
comment:1 Changed 13 years ago by
Milestone: | → 1.1 |
---|---|
Owner: | changed from slightlyoff to alex |
comment:2 Changed 13 years ago by
Milestone: | 1.1 → 1.2 |
---|
comment:3 Changed 13 years ago by
Milestone: | 1.2 → future |
---|
defer dormant enhancements to "future" (they don't look like they're getting fixed soon so might as well mark as such)
comment:5 Changed 10 years ago by
Description: | modified (diff) |
---|---|
Milestone: | future → 1.8 |
comment:6 Changed 9 years ago by
Milestone: | 1.8 → 2.0 |
---|---|
Owner: | changed from dylan to Kris Zyp |
Status: | new → assigned |
Is this relevant for dojo/on? Assigning to Kris to consider for 2.0.
comment:7 Changed 9 years ago by
Component: | General → Query |
---|
(I've been putting the NodeList tickets under the Query category IIRC)
comment:8 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Yes, this issue was solved with dojo/on.
comment:9 Changed 9 years ago by
I don't get it, how does dojo/on solve this? (Also, if it's really fixed by dojo/on the milestone should be set to 1.7, to indicate that it was fixed in 1.7).
comment:10 Changed 9 years ago by
Milestone: | 2.0 → 1.7 |
---|
Oh I see, NodeList.on() returns a list of handles, rather than a list of nodes.
Move all milestone 1.1 tickets to 1.2, except for reopened tickets and tickets opened after 1.1RC1 was released.