Thank you!

This is exactly what I'm after....

Cheers, Nick




On Mar 26, 4:34 pm, mkmanning <michaell...@gmail.com> wrote:
> "a dynamic list" implies something more semantic than a row of divs,
> say a UL or DL...but if you want divs, here's a quick example:
>
> <div id="template" style="display:none;"><!-- everything inside this
> div will be cloned -->
>         <div><input type="text" id="tmp_input" /><button></button></div>
> </div>
>
> $(document).ready(function(){
> $('#template div').clone().find('input').attr
> ('tmp_input','your_new_id').end().find('button').text('Hello').end
> ().appendTo('body');
>
> });
>
> What attributes to change and where you inject the cloned html into
> the DOM is up to you (as is chaining or not). You'll probably want to
> wrap the code above in a function and pass the IDs and HTML into it;
> just replace the hard-coded values with those arguments.
>
> Since you're working with DOM elements, you can use jQuery's methods
> for modifying attributes and html/text (check out the docs for the
> many ways to do that).
>
> On Mar 26, 9:11 am, "nmiddlew...@gmail.com"
>
> <nmiddlew...@googlemail.com> wrote:
> > Hi, thanks for your reply...
>
> > I was thinking of storing the template in the DOM so it's visible by
> > our web designer to tweat. How would I read that template (DIV block)
> > into a javascript variable?
>
> > Thanks for your help!
>
> > On Mar 26, 3:44 pm, MorningZ <morni...@gmail.com> wrote:
>
> > > of course it's possible.....
>
> > > you'd use:
> > > - a variable that contains the string that is the template
> > > - JavaScript's ".replace" method to fill in the ID and HTML
>
> > > also, there's plenty of template plugins out there (chain.js,
> > > jTemplate)
>
> > > On Mar 26, 11:34 am, nmiddleweek <nmiddlew...@googlemail.com> wrote:
>
> > > > Hello,
>
> > > > I'm trying to create a dynamic list of data using jQuery... Each row
> > > > will have an INPUT and a BUTTON element.
>
> > > > I'm thinking of holding a hidden 'template' for each row and then
> > > > duplicating the 'template' row for each row needed and then edit the
> > > > ID and innerHTML of the DOM elements for that row...
>
> > > > Is this possible?
>
> > > > Thanks,
> > > > Nick

Reply via email to