On Sun, Feb 6, 2011 at 3:15 PM, אריה גלזר <arieh.gla...@gmail.com> wrote: > > > On Sun, Feb 6, 2011 at 12:46 PM, Max Vasiliev <max-at-w...@yandex.ru> wrote: >> >> BTW, agreed you should create a custom widget which will have >> 'setChecked' method. > > As I said - I would rather not create a costume event. I want something that > bubbles. I'm creating costume input fields. The point is that I want to be > able to inject the in a way that will behave like normal inputs - so if a > form needs to submit on change, it can do that with delegation instead of > subscribing to each input separately. I want separation between the form > management and the input creation. > > right now I'm using a mitigating observer that observes the inputs and is > observed by the form. something like: > > var observer = new Events;// (mootools generic events class) > form.addEvent('change',function(value){ > this.submit(); > }); > > var ci = new CostumInput;//just for example > > ci.addEvent('change',function(v){ > observer.fireEvent('change',v); > }); > > this obviously works but it feels weird doing this when the DOM already > supports a better mechanism for notifying parents their children fired > events. >
On W3C browsers you should be able to "capture" the "change" event without problems. var handler = function(e) { alert(e.target); /* e.target.form.submit(); */ }; document.addEventListener('change', handler, true); On other non-compliant browsers you can use the event "bubbling" phase to check the parent form for the "click" event or the activation event and do your processing on the control elements to check their state and values. -- Diego > -- > Arieh Glazer > אריה גלזר > 052-5348-561 > http://www.arieh.co.il > http://www.link-wd.co.il > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/jsmentors@jsmentors.com/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/jsmentors@googlegroups.com/ > > To unsubscribe from this group, send email to > jsmentors+unsubscr...@googlegroups.com > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com