myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abushammala, Hani (EXTERN: FTP)" <extern.hani.abushamma...@volkswagen.de>
Subject AW: [Tobago] Javascript reload after Ajax Request.
Date Mon, 14 Jun 2010 13:08:44 GMT
Hi Volker,

I've tried to load a js file with Tobago.ScriptLoader, but i got the message "myFunction is
not defined". Then i've tried to call the function dirctly by letting the array empty, but
the function was called for just a once at time. What am I Doing Wrong?

Code->

<tc:out escape="false" value="<script type=\"text/javascript\">new Tobago.ScriptLoader(['/MyApp/myScript.js'],
'myFunction();');</script>" />
Or:
<tc:out escape="false" value="<script type=\"text/javascript\">new Tobago.ScriptLoader([],
'initFunctionOnLoad();');</script>" /> 

Regards,
Hani

-----Urspr├╝ngliche Nachricht-----
Von: weber.volker@googlemail.com [mailto:weber.volker@googlemail.com] Im Auftrag von Volker
Weber
Gesendet: Montag, 14. Juni 2010 09:35
An: MyFaces Discussion
Betreff: Re: [Tobago] Javascript reload after Ajax Request.

Hi,

in tobago 1.0.x is no support for tc:script during ajaxReload :-(
It is planned for 1.5, but, afaik, not implemented yet.

You can solve this in 1.0.x by using a tc:out with script content
inside the ajax reloaded panel.

eg. replace a
<tc:script file="scripts/myFunctions.js" onload="jsFunction()" />
with a
<tc:out escape="false"
          value="<script type=\"text/javascript\">new
Tobago.ScriptLoader(['ABSOLUTE_URL_TO_myFunctions.js'],
'jsFunction();');</script>" />

The Tobago.ScriptLoader is the javascript function which is used by
tobago internally to handle component reinitializing after (re)load.
It takes a array of urls to load, if not already loaded, and a
javascript to execute after files are loaded.
If you look into the generated html source you can find some of this scripts.

You can let the array empty if the script files are already loaded via
tc:script.


Note: you must calculate those tc:outs into the layout constraints.


Regards,
    Volker

2010/6/11 Werner Punz <werner.punz@gmail.com>:
> Hi I am not familiar with Tobago in this case,
> but it is generally like that that elements loose attached event listeners
> (if they are dynamically attached) if the node is refreshed.
>
> The trick to cope with this is to intercept the ajax call once it is done ad
> reattach those events.
>
> JSF2 for instance has a special event listener api to cope with stuff like
> that, I am rather sure that you have something similar in your setup.
>
> Werner
>
>
>
> Am 11.06.10 15:15, schrieb Abushammala, Hani (EXTERN: FTP):
>>
>> Hello,
>>
>> I have the same Problem on a sheet, i`ve registered event listener to
>> some element by loading of the page.
>> But after the sheet is refreshed via Ajax (e.g. sorting), the jscript
>> function will be not called again.
>>
>>
>> Regars,
>> Hani
>>
>> 2007/4/9, madan chowdary<mada...@yahoo.com>:
>>
>> Hi All,
>>
>> I was just working with JavaScript in Tobago pages.
>>
>> I used onload function to call a javascript function which is used to
>> Event.observe() on some components.
>>
>> These scripts are placed in a panel which gets refreshed via Ajax.
>>
>> The first time the page loads, then the desired task is achieved.
>>
>> But if the panel is refreshed via Ajax, then the javascript is not
>> working.
>>
>> I need to call the function which was done onload, the same way when the
>> panel is refreshed via Ajax.
>>
>> Is this possible ?
>>
>> Regards, Madan
>>
>
>
>



-- 
inexso - information exchange solutions GmbH
Bismarckstra├če 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Mime
View raw message