Wondering what is the best way to react to field changes and do something with the field. i was trying Form.Observer, however it looks like this only gets passed the serialized contents of the form, not the actual element which was changed. Am I missing something? new Form.Observer($(form), 0.3, function(form, value){ console.log(value); }); What would you suggest as as the best route? Whenever a field in my form is changed I want to do some checks based on it''s class, so I need to return the element. Should I assign a listener to each field? Should I try to get it to work with one listener and use bubbling? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Bubbling seems like the answer to me. Put any listeners you need (change, select, click, etc.) on the form element, and then in your callback, use event.element() to get the source element. From there you can look at the new value. -Fred On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswalch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Should I assign a listener to each field? Should I try to get it to > work with one listener and use bubbling?-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Are you saying I need to assign a listener to each input field? On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Bubbling seems like the answer to me. Put any listeners you need (change, > select, click, etc.) on the form element, and then in your callback, use > event.element() to get the source element. From there you can look at the > new value. > > -Fred > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Should I assign a listener to each field? Should I try to get it to > > work with one listener and use bubbling? > > -- > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I think this should be "fixed". Knowing which element was changed is often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, you can use this as a workaround: new Form.Observer($(form), 0.3, (function(){ var previousValue = $(form).serialize(true), element; return function(form, value) { value = value.parseQuery(); for (var prop in value) { if (value[prop] !== previousValue[prop]) { element = $(form).down(''[name='' + prop +'']''); break; } } previousValue = value; // use "element" variable which references changed element } })()); Best, kangax On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you saying I need to assign a listener to each input field? > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > select, click, etc.) on the form element, and then in your callback, use > > event.element() to get the source element. From there you can look at the > > new value. > > > -Fred > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Should I assign a listener to each field? Should I try to get it to > > > work with one listener and use bubbling? > > > -- > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks kangax, nice to see this was already addressed. Do you know if it is included in any of the stable releases? In the meantime I will use your suggestion - which works perfectly. On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think this should be "fixed". Knowing which element was changed is > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > you can use this as a workaround: > > new Form.Observer($(form), 0.3, (function(){ > var previousValue = $(form).serialize(true), element; > return function(form, value) { > value = value.parseQuery(); > for (var prop in value) { > if (value[prop] !== previousValue[prop]) { > element = $(form).down(''[name='' + prop +'']''); > break; > } > } > previousValue = value; > // use "element" variable which references changed element > } > > })()); > > Best, > kangax > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Are you saying I need to assign a listener to each input field? > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > select, click, etc.) on the form element, and then in your callback, use > > > event.element() to get the source element. From there you can look at the > > > new value. > > > > -Fred > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Should I assign a listener to each field? Should I try to get it to > > > > work with one listener and use bubbling? > > > > -- > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I agree this would be nice on the Periodical Observer, but I think what the initial reply was hinting at was this: $(''myform'').observe(''change'', function(evt){ alert(evt.element().id); } ); Walter On Jun 10, 2008, at 2:40 PM, kangax wrote:> > I think this should be "fixed". Knowing which element was changed is > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > you can use this as a workaround: > > new Form.Observer($(form), 0.3, (function(){ > var previousValue = $(form).serialize(true), element; > return function(form, value) { > value = value.parseQuery(); > for (var prop in value) { > if (value[prop] !== previousValue[prop]) { > element = $(form).down(''[name='' + prop +'']''); > break; > } > } > previousValue = value; > // use "element" variable which references changed element > } > })()); > > Best, > kangax > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Are you saying I need to assign a listener to each input field? >> >> On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: >> >>> Bubbling seems like the answer to me. Put any listeners you need >>> (change, >>> select, click, etc.) on the form element, and then in your >>> callback, use >>> event.element() to get the source element. From there you can >>> look at the >>> new value. >> >>> -Fred >> >>> On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> wrote: >>>> Should I assign a listener to each field? Should I try to get it to >>>> work with one listener and use bubbling? >> >>> -- >>> Science answers questions; philosophy questions answers. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 11, 2:02 am, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote:> Bubbling seems like the answer to me. Put any listeners you need (change,The change event doesn''t bubble in the MS HTML DOM. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You know, I did run into this about three months back on a web project I was working on. Extremely annoying indeed! Thanks for the clarification. On Tue, Jun 10, 2008 at 6:46 PM, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> > On Jun 11, 2:02 am, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > Bubbling seems like the answer to me. Put any listeners you need > (change, > > The change event doesn''t bubble in the MS HTML DOM.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
This is not included anywhere yet. In the upcoming release we try to focus on bugfixes (and general polishing), so any enhancements will most likely have to wait for some time. I made a quick patch for this, but haven''t had time to write unit tests yet. http://prototype.lighthouseapp.com/attachments/26787/0001-Form.Observer-to-pass-changed-element-to-a-callback.patch - kangax On Jun 10, 2:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks kangax, nice to see this was already addressed. > Do you know if it is included in any of the stable releases? > > In the meantime I will use your suggestion - which works perfectly. > > On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I think this should be "fixed". Knowing which element was changed is > > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > > you can use this as a workaround: > > > new Form.Observer($(form), 0.3, (function(){ > > var previousValue = $(form).serialize(true), element; > > return function(form, value) { > > value = value.parseQuery(); > > for (var prop in value) { > > if (value[prop] !== previousValue[prop]) { > > element = $(form).down(''[name='' + prop +'']''); > > break; > > } > > } > > previousValue = value; > > // use "element" variable which references changed element > > } > > > })()); > > > Best, > > kangax > > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Are you saying I need to assign a listener to each input field? > > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > > select, click, etc.) on the form element, and then in your callback, use > > > > event.element() to get the source element. From there you can look at the > > > > new value. > > > > > -Fred > > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Should I assign a listener to each field? Should I try to get it to > > > > > work with one listener and use bubbling? > > > > > -- > > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
kangax, I noticed that if there are two inputs with the same name it will always return the first occurance of the double item. Even if the field you are updating is not one of the repeated items. Don''t know if this will impact the patch too. On Jun 10, 11:34 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is not included anywhere yet. > In the upcoming release we try to focus on bugfixes (and general > polishing), so any enhancements will most likely have to wait for some > time. > I made a quick patch for this, but haven''t had time to write unit > tests yet.http://prototype.lighthouseapp.com/attachments/26787/0001-Form.Observ... > > - kangax > > On Jun 10, 2:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks kangax, nice to see this was already addressed. > > Do you know if it is included in any of the stable releases? > > > In the meantime I will use your suggestion - which works perfectly. > > > On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I think this should be "fixed". Knowing which element was changed is > > > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > > > you can use this as a workaround: > > > > new Form.Observer($(form), 0.3, (function(){ > > > var previousValue = $(form).serialize(true), element; > > > return function(form, value) { > > > value = value.parseQuery(); > > > for (var prop in value) { > > > if (value[prop] !== previousValue[prop]) { > > > element = $(form).down(''[name='' + prop +'']''); > > > break; > > > } > > > } > > > previousValue = value; > > > // use "element" variable which references changed element > > > } > > > > })()); > > > > Best, > > > kangax > > > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Are you saying I need to assign a listener to each input field? > > > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > > > select, click, etc.) on the form element, and then in your callback, use > > > > > event.element() to get the source element. From there you can look at the > > > > > new value. > > > > > > -Fred > > > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Should I assign a listener to each field? Should I try to get it to > > > > > > work with one listener and use bubbling? > > > > > > -- > > > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Also, i am finding that it errors if your input name is an array. E.g. foo[bar] Do you know how to fix this. Should I apply the patch? Would that fix it? On Jun 12, 2:53 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> kangax, I noticed that if there are two inputs with the same name it > will always return the first occurance of the double item. Even if the > field you are updating is not one of the repeated items. > Don''t know if this will impact the patch too. > > On Jun 10, 11:34 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > This is not included anywhere yet. > > In the upcoming release we try to focus on bugfixes (and general > > polishing), so any enhancements will most likely have to wait for some > > time. > > I made a quick patch for this, but haven''t had time to write unit > > tests yet.http://prototype.lighthouseapp.com/attachments/26787/0001-Form.Observ... > > > - kangax > > > On Jun 10, 2:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Thanks kangax, nice to see this was already addressed. > > > Do you know if it is included in any of the stable releases? > > > > In the meantime I will use your suggestion - which works perfectly. > > > > On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I think this should be "fixed". Knowing which element was changed is > > > > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > > > > you can use this as a workaround: > > > > > new Form.Observer($(form), 0.3, (function(){ > > > > var previousValue = $(form).serialize(true), element; > > > > return function(form, value) { > > > > value = value.parseQuery(); > > > > for (var prop in value) { > > > > if (value[prop] !== previousValue[prop]) { > > > > element = $(form).down(''[name='' + prop +'']''); > > > > break; > > > > } > > > > } > > > > previousValue = value; > > > > // use "element" variable which references changed element > > > > } > > > > > })()); > > > > > Best, > > > > kangax > > > > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Are you saying I need to assign a listener to each input field? > > > > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > > > > select, click, etc.) on the form element, and then in your callback, use > > > > > > event.element() to get the source element. From there you can look at the > > > > > > new value. > > > > > > > -Fred > > > > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Should I assign a listener to each field? Should I try to get it to > > > > > > > work with one listener and use bubbling? > > > > > > > -- > > > > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Does it error with patch applied? - kangax On Jun 12, 5:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Also, i am finding that it errors if your input name is an array. E.g. > foo[bar] > > Do you know how to fix this. Should I apply the patch? Would that fix > it? > > On Jun 12, 2:53 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > kangax, I noticed that if there are two inputs with the same name it > > will always return the first occurance of the double item. Even if the > > field you are updating is not one of the repeated items. > > Don''t know if this will impact the patch too. > > > On Jun 10, 11:34 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > This is not included anywhere yet. > > > In the upcoming release we try to focus on bugfixes (and general > > > polishing), so any enhancements will most likely have to wait for some > > > time. > > > I made a quick patch for this, but haven''t had time to write unit > > > tests yet.http://prototype.lighthouseapp.com/attachments/26787/0001-Form.Observ... > > > > - kangax > > > > On Jun 10, 2:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Thanks kangax, nice to see this was already addressed. > > > > Do you know if it is included in any of the stable releases? > > > > > In the meantime I will use your suggestion - which works perfectly. > > > > > On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I think this should be "fixed". Knowing which element was changed is > > > > > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > > > > > you can use this as a workaround: > > > > > > new Form.Observer($(form), 0.3, (function(){ > > > > > var previousValue = $(form).serialize(true), element; > > > > > return function(form, value) { > > > > > value = value.parseQuery(); > > > > > for (var prop in value) { > > > > > if (value[prop] !== previousValue[prop]) { > > > > > element = $(form).down(''[name='' + prop +'']''); > > > > > break; > > > > > } > > > > > } > > > > > previousValue = value; > > > > > // use "element" variable which references changed element > > > > > } > > > > > > })()); > > > > > > Best, > > > > > kangax > > > > > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Are you saying I need to assign a listener to each input field? > > > > > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > > > > > select, click, etc.) on the form element, and then in your callback, use > > > > > > > event.element() to get the source element. From there you can look at the > > > > > > > new value. > > > > > > > > -Fred > > > > > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8@public.gmane.orgm> wrote: > > > > > > > > Should I assign a listener to each field? Should I try to get it to > > > > > > > > work with one listener and use bubbling? > > > > > > > > -- > > > > > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Did not work with the patch. Works with the change you suggested $(''foo'').down(''[name="''+ prop +''"]''); Can you add this to the patch so it''s included in the next release? Thanks so much for the help. On Jun 13, 1:47 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Does it error with patch applied? > > - kangax > > On Jun 12, 5:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Also, i am finding that it errors if your input name is an array. E.g. > > foo[bar] > > > Do you know how to fix this. Should I apply the patch? Would that fix > > it? > > > On Jun 12, 2:53 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > kangax, I noticed that if there are two inputs with the same name it > > > will always return the first occurance of the double item. Even if the > > > field you are updating is not one of the repeated items. > > > Don''t know if this will impact the patch too. > > > > On Jun 10, 11:34 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > This is not included anywhere yet. > > > > In the upcoming release we try to focus on bugfixes (and general > > > > polishing), so any enhancements will most likely have to wait for some > > > > time. > > > > I made a quick patch for this, but haven''t had time to write unit > > > > tests yet.http://prototype.lighthouseapp.com/attachments/26787/0001-Form.Observ... > > > > > - kangax > > > > > On Jun 10, 2:55 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Thanks kangax, nice to see this was already addressed. > > > > > Do you know if it is included in any of the stable releases? > > > > > > In the meantime I will use your suggestion - which works perfectly. > > > > > > On Jun 10, 2:40 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I think this should be "fixed". Knowing which element was changed is > > > > > > often crucial. I''ll make a patch as soon as I get a chance. Meanwhile, > > > > > > you can use this as a workaround: > > > > > > > new Form.Observer($(form), 0.3, (function(){ > > > > > > var previousValue = $(form).serialize(true), element; > > > > > > return function(form, value) { > > > > > > value = value.parseQuery(); > > > > > > for (var prop in value) { > > > > > > if (value[prop] !== previousValue[prop]) { > > > > > > element = $(form).down(''[name='' + prop +'']''); > > > > > > break; > > > > > > } > > > > > > } > > > > > > previousValue = value; > > > > > > // use "element" variable which references changed element > > > > > > } > > > > > > > })()); > > > > > > > Best, > > > > > > kangax > > > > > > > On Jun 10, 1:34 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Are you saying I need to assign a listener to each input field? > > > > > > > > On Jun 10, 12:02 pm, "Frederick Polgardy" <f...-SMQUYeM9IBBWk0Htik3J/w@public.gmane.org> wrote: > > > > > > > > > Bubbling seems like the answer to me. Put any listeners you need (change, > > > > > > > > select, click, etc.) on the form element, and then in your callback, use > > > > > > > > event.element() to get the source element. From there you can look at the > > > > > > > > new value. > > > > > > > > > -Fred > > > > > > > > > On Tue, Jun 10, 2008 at 10:22 AM, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Should I assign a listener to each field? Should I try to get it to > > > > > > > > > work with one listener and use bubbling? > > > > > > > > > -- > > > > > > > > Science answers questions; philosophy questions answers.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---