Hi all, I was playing around with MochiKit.Signal, specifically asking the question: "Can I use MochiKit.Signal.connect to set event handlers for objects that don't exist yet.
Like so: // connect to our make a new button button MochiKit.Signal.connect("button_that_exists", 'onclick', function(evt ) { var new_button = MochiKit.DOM.BUTTON({'id': "newly_created_button"}, "Hello world, I'm new"); MochiKit.DOM.appendChildNodes( MochiKit.DOM.getElement("main_content_div"), new_button ); }); MochiKit.Signal.connect("newly_created_button", 'onclick', function(evt) { alert("hey world"); }); NOTE that "newly_created_button" won't exist until the user clicks the "button_that_exists". When I try this I get an error in MochiKit.Signal, about src being null. Is this a bug ("MochiKit.Signal should allow connecting to DOM objects that don't exist yet"), or a limitation of how MochiKit.Signal was designed ("MochiKit.Signal.connect supports only objects that live on the DOM when it is called")? I do see that MochiKit.Signal.signal DOES seem to support the src object being a string, so I suspect the former answer. If it is the former answer (if this error is a bug) I can try to put together a patch to try and allow this behavior, BUT I wanted to check before I went down this road. To see my full example, I've pushed it up to Bitbucket (as part of a "learning" repository, so there's a lot of extra stuff in there :( ): <http://bitbucket.org/rwilcox/learning_javascript/src/tip/MochiKit/ signals_and_slots/> -- You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochi...@googlegroups.com. To unsubscribe from this group, send email to mochikit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mochikit?hl=en.