You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Inge Solvoll <in...@gmail.com> on 2009/10/09 17:18:31 UTC

Javascript not included on Ajax.Request

Hi!

I use prototype Ajax.Request to load a tapestry page url into a non-tapestry
page. The response content is appended to the document with javascript.

My problem is that javascript that is included in the tapestry page seems to
not be included/interpreted in the browser when the content is received via
XmlHttpRequest. It all works if I do a normal page render.

Is this supposed to work, or do I have to find some other approach?

Re: Javascript not included on Ajax.Request

Posted by Andreas Andreou <an...@di.uoa.gr>.
That's normal - you need to look at the prototype docs to see if there's a
helper function that will run the scripts of an ajax response... or if there's
a helper that appends html to the current document AND executes the included
(in that html) scripts.

I know dojo has something similar, perhaps prototype has that too

On Fri, Oct 9, 2009 at 6:18 PM, Inge Solvoll <in...@gmail.com> wrote:
> Hi!
>
> I use prototype Ajax.Request to load a tapestry page url into a non-tapestry
> page. The response content is appended to the document with javascript.
>
> My problem is that javascript that is included in the tapestry page seems to
> not be included/interpreted in the browser when the content is received via
> XmlHttpRequest. It all works if I do a normal page render.
>
> Is this supposed to work, or do I have to find some other approach?
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Javascript not included on Ajax.Request

Posted by Inge Solvoll <in...@gmail.com>.
Thanks for the feedback, you guys!

I did some more research, and found that Ajax.Updater actually is better, it
does everything that I've done manually until now. And in addition, it has
an "evalScripts" option, which claims pass all <script> blocks to the eval()
function. But my included script file is still not available, so I guess
this means that only inline scripts are evaluated, not included script
files.

The scripts I need are quite short, so I tried to solve this by using
renderSupport.addScript rather than including entire script files. But that
doesn't work either, since they are wrapped in Tapestry.onDOMLoaded(), which
doesn't exist on my non-tapestry page and isn't evaluated in the AJAX-loaded
T5 page...

My third option was to just use MarkupWriter to write my own script tag with
my inline script in there. That didn't work either, I got an error about
duplicate root tag <html> on my page.

I'm stumped, so I guess I'll try an entirely different approach :)

Thanks for your help anyway!

Inge

On Fri, Oct 9, 2009 at 7:53 PM, Christian Riedel
<ch...@gmx.net>wrote:

> i dont know if i get your problem right, but if the tapestry.js is
> available, you can use some of its magic:
>
> the value of the key "script" will be evaluated by the tapestry.js!
>
> JSonObject j = new JSonObject();
> j.put("script", "alert('hi!');");
> return j;
>
>
> regards
> christian
>
>
> cordenier christophe schrieb:
>
>  Hi
>>
>> If you only append content i don't think it will work. Have a look at how
>> Tapestry achieve JS loading in loadScriptsInReply method of 'tapestry.js'
>> file.
>>
>> christophe.
>>
>> 2009/10/9 Inge Solvoll <in...@gmail.com>
>>
>>
>>
>>> Hi!
>>>
>>> I use prototype Ajax.Request to load a tapestry page url into a
>>> non-tapestry
>>> page. The response content is appended to the document with javascript.
>>>
>>> My problem is that javascript that is included in the tapestry page seems
>>> to
>>> not be included/interpreted in the browser when the content is received
>>> via
>>> XmlHttpRequest. It all works if I do a normal page render.
>>>
>>> Is this supposed to work, or do I have to find some other approach?
>>>
>>>
>>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Javascript not included on Ajax.Request

Posted by Christian Riedel <ch...@gmx.net>.
i dont know if i get your problem right, but if the tapestry.js is 
available, you can use some of its magic:

the value of the key "script" will be evaluated by the tapestry.js!

JSonObject j = new JSonObject();
j.put("script", "alert('hi!');");
return j;


regards
christian


cordenier christophe schrieb:
> Hi
>
> If you only append content i don't think it will work. Have a look at how
> Tapestry achieve JS loading in loadScriptsInReply method of 'tapestry.js'
> file.
>
> christophe.
>
> 2009/10/9 Inge Solvoll <in...@gmail.com>
>
>   
>> Hi!
>>
>> I use prototype Ajax.Request to load a tapestry page url into a
>> non-tapestry
>> page. The response content is appended to the document with javascript.
>>
>> My problem is that javascript that is included in the tapestry page seems
>> to
>> not be included/interpreted in the browser when the content is received via
>> XmlHttpRequest. It all works if I do a normal page render.
>>
>> Is this supposed to work, or do I have to find some other approach?
>>
>>     
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Javascript not included on Ajax.Request

Posted by cordenier christophe <ch...@gmail.com>.
Hi

If you only append content i don't think it will work. Have a look at how
Tapestry achieve JS loading in loadScriptsInReply method of 'tapestry.js'
file.

christophe.

2009/10/9 Inge Solvoll <in...@gmail.com>

> Hi!
>
> I use prototype Ajax.Request to load a tapestry page url into a
> non-tapestry
> page. The response content is appended to the document with javascript.
>
> My problem is that javascript that is included in the tapestry page seems
> to
> not be included/interpreted in the browser when the content is received via
> XmlHttpRequest. It all works if I do a normal page render.
>
> Is this supposed to work, or do I have to find some other approach?
>