On Aug 19, 11:45 am, 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?

You can put Mako/JS templates in your templates directory and then
render them from your HTML template with something like <script src="$
{url('/templates/javascripts/whizbang.js')}"></script>.

Otherwise, if you're writing the JS inline in the HTML template (ew?),
then you should just be able to use `c` in the usual way:

<script>
  var get_pants = function () {
    var pants = '${c.pants}';
    return pants;
  }
  var make_stuff_from_list = function () {
    % for thing in c.list_of_things:
      new Thing('${thing.title}', ${thing.quantity});
    % endfor
  }
</script>

-- 
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.

Reply via email to