On Thu, Aug 19, 2010 at 2:45 PM, Krishnakant Mane <[email protected]> wrote: > Hello, > Might be this is too easy and I am overlooking some simple solution. > But really, I am not finding a way to include a value from tmpl_context > inside a javascript function. > what if I am creating a form that will have dynamically added rows and each > row has a dropdown list containing some data. > If it was a static form I could just write <input type = ... value = > ${c.names}> > this also applies to text entries which might need to hold data received > from the pylons controller action. > so if I were to create form fields inside a javascript function, i will need > to some how access ${c.Whatever} and get the pre-populated field generated. > Then I can use jquery to perhaps duplicate rows of such form fields. > Is there a way to accomplish this task?
What I've done in this situation is to create a <select id="some_template">... that is hidden at the bottom of the page. This is generated by the mako template when the page is loaded. Your JS can then use that as a model of a select box for the new rows. You just end up grabbing the node and duplicating it. Since you mention jQuery check out: http://api.jquery.com/clone/ This way you store what you need to reuse in the page itself and then pull it out when you need via the client side JS. Rick Harding http://blog.mitechie.com -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
