Javascript, AJAX, and TAL

I’m working on adding a bit of AJAX to my portlets. One thing that I noticed is that TAL expressions don’t seem to work inside a <script> tag. I ended up with something like functionCall(<span tal:replace=”context/blah” />) in the page source – not quite what I was going for.

A bit of digging around showed me how to get around this. Generate your script tags like this:

<tal:block tal:replace=”structure string:& lt;script language=’Javascript’ type=’text/javascript’& gt;” />

Javascript goes here.

<tal:block tal:replace=”structure string:& lt;/ script& gt;” />

I can’t seem to get around WordPress’ auto formatting.  I put a space between the & lt; and & gt; notations so that you could see what I did.  Put them back together to use this code in a template.

Advertisements

~ by Liz on April 8, 2008.

One Response to “Javascript, AJAX, and TAL”

  1. Thanks, that really helped me. 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: