Opened 15 years ago
Closed 15 years ago
#238 closed defect (invalid)
event.connect breaks with function object as the 3rd argument
Reported by: | david | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Core | Version: | 0.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I have:
function Foo() { // constructor! } Foo.prototype = { /* ... */ }; Foo.listener = function(e) { dojo.debug(e.target); } dojo.event.connect(window, "onclick", Foo, "listener");
Foo.prototype
still exists, but all the static properties have been wiped. This is bad.
Change History (2)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
The third argument is a reference to an object which event.connect *will* modify, in the most unobtrusive way possible, to set up the connection. The example you have here is a contstructor function...event.connect alters the function (because it is also an object) correctly but there are side effects which you are observing. What you need to do is:
function Foo() { // constructor! } Foo.prototype = { /* ... */ }; Foo.listener = function(e) { dojo.debug(e.target); } var bar=new Foo(); dojo.event.connect(window, "onclick", bar, "listener");
because you want to connect an instance and not the actual constructor.
Note: See
TracTickets for help on using
tickets.
So while kwConnect doesn't cause errors, the event didn't seem to connect.