Hi all,

I'm currently building a new Pylons project and started to use Mako
instead of Myghty for templating. For the record, I'm running Pylons
0.9.5, Mako 0.1.5 and WebHelpers 0.3 on an Ubuntu Linux 7.04 box with
Python 2.5.

Background:

In one of my Mako templates, I want to include some (simple) AJAX
niceties for showing help information alongside the actual data. This
is implemented by updating appropriate DOM elements whenever the user
clicks on a "?" link next to the actual information.


The Problem:

Here's the snippet of my Mako template to output the required
JavaScript via WebHelpers:

=============== snipp ================
${h.link_to_function("?",
h.update_element_function("dom_element_to_be_updated", content="foo
bar"))}
=============== snipp ================

The resulting output of the template is:

=============== snipp ================
<a href="#" onclick="$('dom_element_to_be_updated').innerHTML = 'foo
bar';
; return false;">?</a>
=============== snipp ================
(as a side note, there is a line break here between the first and the
second line)

Clicking the "?" link above results in the error "$ is not defined" in
Firefox's error console. The problematic part of the output comes from
h.update_element_function() - I could confirm that it is not (only)
related to the combination of h.link_to_remote() and
h.update_element_function().

The correct HTML/JavaScript output should be more like:

=============== snipp ================
<a href="#" onclick="dom_element_to_be_updated.innerHTML = 'foo bar';
return false;">?</a>
=============== snipp ================

Here, clicking on the "?" link updates the DOM element correctly.

Now my question is: am I missing something? I tried different
variations to get the code I wanted, like trying to output the JS code
from h.update_element_function() via a standard print statement from a
Python block <% ... %> (which didn't output anything by the way,
similar to Antipin's findings [1]).

I couldn't find anything related in this discussion group or in Mako's
own discussion group; I also searched the Trac tickets of both without
success.

Any help would be appreciated,
Michael


[1] 
http://groups.google.com/group/pylons-discuss/browse_thread/thread/c08e4a908e41a5a0/3717f548d8bdad89


PS: Before switching to Mako, I used the same WebHelpers code in
Myghty and it worked flawlessly.


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