Re: [mochikit] Mochikit.signal and DOM objects that don't exist yet (like jQuery.live)
Thanks for your input to the project, but I don't think we can consider this a bug. Referring to objects that do not yet exist is an error in almost any programming language, so it is to be expected. The MochiKit docs do not explicitly make it clear that the id lookup is immediate, but they definitely do not discuss any lazy or delayed lookup of the signal source. The documentation is explicit regarding that the destination slot will be looked up on the first signal, though. In your case, why wouldn't you just attach the signal when creating the element? Otherwise you'd have to listen to any DOM modification and possibly attach signals to elements added. And that use case sounds pretty specific to me. BTW. If you'd like to contribute patches to the MochiKit project, it would be much easier if you forked the project on GitHub I think. The move happened quite recently, so I haven't moved all my own patches yet, but by forking on GitHub it becomes much easier for us maintainers to pick up patches and ideas. Cheers, /Per On Fri, Dec 3, 2010 at 16:37, ryanwil...@gmail.com ryanwil...@gmail.com wrote: 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. -- 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.
Re: [mochikit] Mochikit.signal and DOM objects that don't exist yet (like jQuery.live)
That said, I think jQuery Live style functionality is useful, and I certainly wouldn't mind seeing some additional module to support it. However, all existing MochiKit functionality works only on the current state of the DOM and it is not a bug that it doesn't consider future changes to the DOM that may match the id or selector given. On Sat, Dec 4, 2010 at 5:58 PM, Per Cederberg p...@percederberg.net wrote: Thanks for your input to the project, but I don't think we can consider this a bug. Referring to objects that do not yet exist is an error in almost any programming language, so it is to be expected. The MochiKit docs do not explicitly make it clear that the id lookup is immediate, but they definitely do not discuss any lazy or delayed lookup of the signal source. The documentation is explicit regarding that the destination slot will be looked up on the first signal, though. In your case, why wouldn't you just attach the signal when creating the element? Otherwise you'd have to listen to any DOM modification and possibly attach signals to elements added. And that use case sounds pretty specific to me. BTW. If you'd like to contribute patches to the MochiKit project, it would be much easier if you forked the project on GitHub I think. The move happened quite recently, so I haven't moved all my own patches yet, but by forking on GitHub it becomes much easier for us maintainers to pick up patches and ideas. Cheers, /Per On Fri, Dec 3, 2010 at 16:37, ryanwil...@gmail.com ryanwil...@gmail.com wrote: 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. -- 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. -- 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.
Re: [mochikit] Does the BSD license need to be mentioned?
Thanks for your feedback! I've updated the license text in the MochiKit repository with your patch: http://github.com/mochi/mochikit/commit/60ac9815cb6a4d63a90936777ea7dc836caf7e94 We'll use the updated license for the 1.5 release (whenever that'll be), but there are no current plans for patching the 1.4.x release further (unless critical bugs are discovered). Feel free to apply you patch to the version packaged in Fedora. Cheers, /Per On Fri, Dec 3, 2010 at 21:45, Toshio Kuratomi a.bad...@gmail.com wrote: Greetings, I was working on MochiKit for Fedora and someone pointed out this bit of licensing: https://github.com/mochi/mochikit/blob/master/MochiKit/Style.js#L165 /* * getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. * Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. * License: BSD, http://developer.yahoo.net/yui/license.txt * */ BSD is compatible with MIT (I haven't checked AFL but we can package under BSD-MIT only if that's an issue) so the issue that was pointed out isn't license compatibility. It's being sure that we comply with the terms of the License. The license text from the yahoo URL says: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. I think that means that LICENSE.txt needs to include the Yahoo BSD license and copyright terms for that function. I'm not sure if the license information should also be included verbatim in the Style.js file. I'll attach a patch to modify LICENSE.txt. -Toshio -- 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.