Richard Quadling
2007-Jun-27 10:02 UTC
Clone a row with inputs for a continuous form effect.
Hi. Has anyone got some code which will allow a form to continuously grow? My idea is to define a hidden "block" which is cloned and appended and the elements which are input tags are re-"name"-d to allow each row to be uniquely identitied when it gets to the server. If someone has done this already, then it would save me reinventing the wheel. Thank you. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What''s the difference in allowing a form to grow, as opposed to any other type of HTML content? It''s the same thing. On Jun 27, 6:02 am, "Richard Quadling" <rquadl...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi. > > Has anyone got some code which will allow a form to continuously grow? > > My idea is to define a hidden "block" which is cloned and appended and > the elements which are input tags are re-"name"-d to allow each row to > be uniquely identitied when it gets to the server. > > If someone has done this already, then it would save me reinventing the wheel. > > Thank you. > > -- > ----- > Richard Quadling > Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!"--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Jun-27 12:49 UTC
Re: Clone a row with inputs for a continuous form effect.
On 27/06/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > What''s the difference in allowing a form to grow, as opposed to any > other type of HTML content? It''s the same thing.The requirement is to have a form which automatically adds new rows when the current last row is populated by hand. Like a DB entry form. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Jun-27 13:04 UTC
Re: Clone a row with inputs for a continuous form effect.
I''ve done it. You it''s pretty easy to do something like this: $("aButton").up("tr").up().appendChild(newRow); assuming that the button which is clicked is within the table you want to grow. The up() function will move you past any other elements to find the row which contains the button and then using that row''s parentNode (which is usually a tbody element, though not always, hence the lack of a parameter) you can just append a new row to the table. I tend to build the row I want to add first and then clone it rather than build it with DOM functions over and over again. Alternatively, I''ve also had the database process which inserts the information into the database return HTML to be handled in an onSuccess action of an Ajax.Updater object with the insertion option set to add the information to the bottom of the specified element. - Dash - Richard Quadling wrote:> On 27/06/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> What''s the difference in allowing a form to grow, as opposed to any >> other type of HTML content? It''s the same thing. >> > > The requirement is to have a form which automatically adds new rows > when the current last row is populated by hand. > > Like a DB entry form. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Jun-27 13:27 UTC
Re: Clone a row with inputs for a continuous form effect.
On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''ve done it. You it''s pretty easy to do something like this: > > $("aButton").up("tr").up().appendChild(newRow); > > assuming that the button which is clicked is within the table you want > to grow. The up() function will move you past any other elements to > find the row which contains the button and then using that row''s > parentNode (which is usually a tbody element, though not always, hence > the lack of a parameter) you can just append a new row to the table. I > tend to build the row I want to add first and then clone it rather than > build it with DOM functions over and over again. Alternatively, I''ve > also had the database process which inserts the information into the > database return HTML to be handled in an onSuccess action of an > Ajax.Updater object with the insertion option set to add the information > to the bottom of the specified element. > > - Dash - > > Richard Quadling wrote: > > On 27/06/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> What''s the difference in allowing a form to grow, as opposed to any > >> other type of HTML content? It''s the same thing. > >> > > > > The requirement is to have a form which automatically adds new rows > > when the current last row is populated by hand. > > > > Like a DB entry form.Thank you. Exactly the sort of thing I''m looking for. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Jun-27 13:41 UTC
Re: Clone a row with inputs for a continuous form effect.
Just don''t assume that you can say: $("aButton").up("table").appendChild( ... ); It works fine in FF2, but it definately breaks IE. You have to figure a way to get the parent of the row which contains your button, which is the purpose of the .up("tr").up() syntax in my example. Frankly, I''d love to see a better way than that since I always have to comment why I''m doing things that way or I worry that the next developer will come around and try and "fix" my code. - Dash - Richard Quadling wrote:> On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> I''ve done it. You it''s pretty easy to do something like this: >> >> $("aButton").up("tr").up().appendChild(newRow); >> >> assuming that the button which is clicked is within the table you want >> to grow. The up() function will move you past any other elements to >> find the row which contains the button and then using that row''s >> parentNode (which is usually a tbody element, though not always, hence >> the lack of a parameter) you can just append a new row to the table. I >> tend to build the row I want to add first and then clone it rather than >> build it with DOM functions over and over again. Alternatively, I''ve >> also had the database process which inserts the information into the >> database return HTML to be handled in an onSuccess action of an >> Ajax.Updater object with the insertion option set to add the information >> to the bottom of the specified element. >> >> - Dash - >> >> Richard Quadling wrote: >> >>> On 27/06/07, Diodeus <diodeus-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> >>>> What''s the difference in allowing a form to grow, as opposed to any >>>> other type of HTML content? It''s the same thing. >>>> >>>> >>> The requirement is to have a form which automatically adds new rows >>> when the current last row is populated by hand. >>> >>> Like a DB entry form. >>> > > > Thank you. Exactly the sort of thing I''m looking for. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Jun-27 14:18 UTC
Re: Clone a row with inputs for a continuous form effect.
On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Just don''t assume that you can say: > > $("aButton").up("table").appendChild( ... ); > > It works fine in FF2, but it definately breaks IE. You have to figure a > way to get the parent of the row which contains your button, which is > the purpose of the .up("tr").up() syntax in my example. Frankly, I''d > love to see a better way than that since I always have to comment why > I''m doing things that way or I worry that the next developer will come > around and try and "fix" my code. > > - Dash -I wouldn''t use a button. I would have an event handler on the onchange event of the inputs, so as each input is entered, I can check to see if it is in the last row. If so, we need to add a new one. So, as you move off first new input in the row, a new row will appear. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Jun-27 14:32 UTC
Re: Clone a row with inputs for a continuous form effect.
Regardless, of what triggers the event, the up("tr").up() function calls are a little weird. - Dave - Richard Quadling wrote:> On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Just don''t assume that you can say: >> >> $("aButton").up("table").appendChild( ... ); >> >> It works fine in FF2, but it definately breaks IE. You have to figure a >> way to get the parent of the row which contains your button, which is >> the purpose of the .up("tr").up() syntax in my example. Frankly, I''d >> love to see a better way than that since I always have to comment why >> I''m doing things that way or I worry that the next developer will come >> around and try and "fix" my code. >> >> - Dash - >> > > I wouldn''t use a button. > > I would have an event handler on the onchange event of the inputs, so > as each input is entered, I can check to see if it is in the last row. > If so, we need to add a new one. > > So, as you move off first new input in the row, a new row will appear. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Jun-27 14:36 UTC
Re: Clone a row with inputs for a continuous form effect.
Ok. Thanks for the warning. On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Regardless, of what triggers the event, the up("tr").up() function calls > are a little weird. > - Dave - > > Richard Quadling wrote: > > On 27/06/07, David Dashifen Kees <dashifen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > >> Just don''t assume that you can say: > >> > >> $("aButton").up("table").appendChild( ... ); > >> > >> It works fine in FF2, but it definately breaks IE. You have to figure a > >> way to get the parent of the row which contains your button, which is > >> the purpose of the .up("tr").up() syntax in my example. Frankly, I''d > >> love to see a better way than that since I always have to comment why > >> I''m doing things that way or I worry that the next developer will come > >> around and try and "fix" my code. > >> > >> - Dash - > >> > > > > I wouldn''t use a button. > > > > I would have an event handler on the onchange event of the inputs, so > > as each input is entered, I can check to see if it is in the last row. > > If so, we need to add a new one. > > > > So, as you move off first new input in the row, a new row will appear. > > > > > > > > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 28, 12:32 am, David Dashifen Kees <dashi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Regardless, of what triggers the event, the up("tr").up() function calls > are a little weird.A tr element *must* be a child of a table section element[1], which is a tbody, thead or tfoot. Assuming the OP isn''t putting new rows into the thead or tfoot, up(''tbody'') should to the trick. 1. tbody tags are optional but every table must have at least one tbody element, so browsers will add it if the tags are missing. <URL: http://www.w3.org/TR/html4/struct/tables.html#edef-TBODY > -- 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 -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees
2007-Jun-28 12:47 UTC
Re: Clone a row with inputs for a continuous form effect.
Yeah, but experience has taught me that non-IE browsers were pretty happy displaying TR elements added outside of a TBODY et. al. regardless of spec. In IE, though, while the element was (presumably) added to the document, nothing was shown. Adding to the parent of the last row seemed to be the way that worked the best for me across all browsers, especially since up("tbody") didn''t work somewhere ... Opera maybe? I don''t remember. - Dash - RobG wrote:> > On Jun 28, 12:32 am, David Dashifen Kees <dashi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Regardless, of what triggers the event, the up("tr").up() function calls >> are a little weird. >> > > A tr element *must* be a child of a table section element[1], which is > a tbody, thead or tfoot. Assuming the OP isn''t putting new rows into > the thead or tfoot, up(''tbody'') should to the trick. > > > 1. tbody tags are optional but every table must have at least one > tbody element, so browsers will add it if the tags are missing. > <URL: http://www.w3.org/TR/html4/struct/tables.html#edef-TBODY > > > > -- > 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 -~----------~----~----~----~------~----~------~--~---
For the IE fix try using ele.up("tbody"), IE doesn''t allow rows to be dynamically appended directly to the table, gotta go through the tbody, don''t worry the Gecko engines will understand this as well. On Jun 28, 8:47 am, David Dashifen Kees <dashi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah, but experience has taught me that non-IE browsers were pretty > happy displaying TR elements added outside of a TBODY et. al. regardless > of spec. In IE, though, while the element was (presumably) added to the > document, nothing was shown. Adding to the parent of the last row > seemed to be the way that worked the best for me across all browsers, > especially since up("tbody") didn''t work somewhere ... Opera maybe? I > don''t remember. > > - Dash - > > RobG wrote: > > > On Jun 28, 12:32 am, David Dashifen Kees <dashi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> Regardless, of what triggers the event, the up("tr").up() function calls > >> are a little weird. > > > A tr element *must* be a child of a table section element[1], which is > > a tbody, thead or tfoot. Assuming the OP isn''t putting new rows into > > the thead or tfoot, up(''tbody'') should to the trick. > > > 1. tbody tags are optional but every table must have at least one > > tbody element, so browsers will add it if the tags are missing. > > <URL:http://www.w3.org/TR/html4/struct/tables.html#edef-TBODY> > > > -- > > 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 -~----------~----~----~----~------~----~------~--~---