[Proto-Scripty] Re: trigger a 'change' event for a 'select' element
Hi Anjanesh, I use a simple bypass to this limitation: when observing an event, if it's a native event, I create a custom event native:click that reference the same call back to the original click observer. So firing this native:click event, does the job. -- david On 29 jan, 16:35, Peter De Berdt peter.de.be...@pandora.be wrote: On 29 Jan 2009, at 16:18, Anjanesh wrote: I need to trigger a 'change' event for a 'select' element. alert($($(elem).parentNode)); // shows [Object HTMLSelectElement] $($(elem).parentNode).fire('change'); // How do I indicate which option value to change to ? But the fire() doesnt work. But no JS errors either. Fromhttp://prototypejs.org/api/element/fire: Element#fire does not support firing native events. All custom event names must be namespaced (using a colon). This is to avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll. What you want to to, is set the selectedIndex value from the select element as is documented athttp://www.w3schools.com/htmldom/dom_obj_select.asp selectedIndex needs to be an integer. If you want to select it by value, then you'll need to loop the values and when you find the right one, check what index it has (selectedIndex is a getter and a setter) and set it to that index. Best regards Peter De Berdt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: trigger a 'change' event for a 'select' element
what's wrong with a simple (regular, no-need-for-external-libraries) onChange like: select id=getmethisselectindex name=getmethisselectindex onChange=myJsFunc(); and in myJsFunc: var myid = $F('getmethisselectindex'); or did i miss something? On Fri, Jan 30, 2009 at 11:59 AM, david david.brill...@gmail.com wrote: Hi Anjanesh, I use a simple bypass to this limitation: when observing an event, if it's a native event, I create a custom event native:click that reference the same call back to the original click observer. So firing this native:click event, does the job. -- david On 29 jan, 16:35, Peter De Berdt peter.de.be...@pandora.be wrote: On 29 Jan 2009, at 16:18, Anjanesh wrote: I need to trigger a 'change' event for a 'select' element. alert($($(elem).parentNode)); // shows [Object HTMLSelectElement] $($(elem).parentNode).fire('change'); // How do I indicate which option value to change to ? But the fire() doesnt work. But no JS errors either. Fromhttp://prototypejs.org/api/element/fire: Element#fire does not support firing native events. All custom event names must be namespaced (using a colon). This is to avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll. What you want to to, is set the selectedIndex value from the select element as is documented athttp://www.w3schools.com/htmldom/dom_obj_select.asp selectedIndex needs to be an integer. If you want to select it by value, then you'll need to loop the values and when you find the right one, check what index it has (selectedIndex is a getter and a setter) and set it to that index. Best regards Peter De Berdt -- Lars Schwarz Heiligengeiststr. 26 26121 Oldenburg T 0441 36110338 M 0151 1727 8127 W www.bitrocker.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: trigger a 'change' event for a 'select' element
Hi Lars, depending on the context, the DOM 0 events is still there and prototype does not break it so you're totally right to remember everybody it's still alive! But some could cry to offense, because of MVC but stop, it could launch a discution I did not want. -- david On 30 jan, 12:58, Lars Schwarz lars.schw...@gmail.com wrote: what's wrong with a simple (regular, no-need-for-external-libraries) onChange like: select id=getmethisselectindex name=getmethisselectindex onChange=myJsFunc(); and in myJsFunc: var myid = $F('getmethisselectindex'); or did i miss something? On Fri, Jan 30, 2009 at 11:59 AM, david david.brill...@gmail.com wrote: Hi Anjanesh, I use a simple bypass to this limitation: when observing an event, if it's a native event, I create a custom event native:click that reference the same call back to the original click observer. So firing this native:click event, does the job. -- david On 29 jan, 16:35, Peter De Berdt peter.de.be...@pandora.be wrote: On 29 Jan 2009, at 16:18, Anjanesh wrote: I need to trigger a 'change' event for a 'select' element. alert($($(elem).parentNode)); // shows [Object HTMLSelectElement] $($(elem).parentNode).fire('change'); // How do I indicate which option value to change to ? But the fire() doesnt work. But no JS errors either. Fromhttp://prototypejs.org/api/element/fire: Element#fire does not support firing native events. All custom event names must be namespaced (using a colon). This is to avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll. What you want to to, is set the selectedIndex value from the select element as is documented athttp://www.w3schools.com/htmldom/dom_obj_select.asp selectedIndex needs to be an integer. If you want to select it by value, then you'll need to loop the values and when you find the right one, check what index it has (selectedIndex is a getter and a setter) and set it to that index. Best regards Peter De Berdt -- Lars Schwarz Heiligengeiststr. 26 26121 Oldenburg T 0441 36110338 M 0151 1727 8127 Wwww.bitrocker.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: trigger a 'change' event for a 'select' element
Hi, The documentation of Element#fire (here[1]) actually makes a point of saying that it can't be used to fire native events. [1] http://prototypejs.org/api/element/fire HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jan 29, 3:18 pm, Anjanesh anjanesh.for...@gmail.com wrote: I need to trigger a 'change' event for a 'select' element. alert($($(elem).parentNode)); // shows [Object HTMLSelectElement] $($(elem).parentNode).fire('change'); // How do I indicate which option value to change to ? But the fire() doesnt work. But no JS errors either. this.settings.each(function(element){ Event.observe(element, 'change', this.configure.bind (this)) }.bind(this)); configure: function(event) { alert(event); var element = Event.element(event); this.configureElement(element); }, If the fire() worked,then alert(event); would've shown something. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: trigger a 'change' event for a 'select' element
On 29 Jan 2009, at 16:18, Anjanesh wrote: I need to trigger a 'change' event for a 'select' element. alert($($(elem).parentNode)); // shows [Object HTMLSelectElement] $($(elem).parentNode).fire('change'); // How do I indicate which option value to change to ? But the fire() doesnt work. But no JS errors either. From http://prototypejs.org/api/element/fire : Element#fire does not support firing native events. All custom event names must be namespaced (using a colon). This is to avoid custom event names conflicting with non-standard native DOM events such as mousewheel and DOMMouseScroll. What you want to to, is set the selectedIndex value from the select element as is documented at http://www.w3schools.com/htmldom/dom_obj_select.asp selectedIndex needs to be an integer. If you want to select it by value, then you'll need to loop the values and when you find the right one, check what index it has (selectedIndex is a getter and a setter) and set it to that index. Best regards Peter De Berdt --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---