PDA

View Full Version : Javascript function in updateManager returned content



Thinka
14 Dec 2006, 8:05 AM
Hi Guys,
Hope everyone is cool. I have had an extensive look around the forums and cannot find an answer to my problem, any suggestions would be appreciated.

The problem: I would like to use the wonderful qforms library http://www.pengoworks.com/index.cfm?action=get:qforms on forms thoughout my site, but I am having trouble getting the javascript to execute. The forms are stored server side and only called into the content panels when needed using the update manager. I see there is a loadScripts property and this works great to run any scripts in the fetched content, but I cannot get access to functions in the returned data after the update is complete. The browser (IE or FF) always reports <function> is not defined. Is this because the returned scripts are not actually added to the DOM.


The real issue is that qform automatically binds to the form onload, hahaha, but baby steps, baby steps.

PS the pagin on the form search seems to fail 8(

Thanks in advance.

David.

jack.slocum
14 Dec 2006, 8:31 AM
Because the function scripts are eval'ed, they are going to be scoped to where they are eval'ed. This means they won't be visible globally. I don't know of any workaround.

Can you modify the functions returned to assign to a globally available object? For example, instead of:

function test(){...}

use

YAHOO.thinka.test = function(){...}

I know this sucks, but then it would be available everywhere.

Thinka
14 Dec 2006, 9:06 AM
Hi Jack,
That's ok. I will use an iframe in a dialogue instead. That should work for now.

Thanks again for the help and the wonderful toolset.

sjivan
14 Dec 2006, 2:34 PM
Because the function scripts are eval'ed, they are going to be scoped to where they are eval'ed. This means they won't be visible globally. I don't know of any workaround.




window[objName] = eval(objName);


should do it. We do this in AjaxAnywhere.

Sanjiv

jack.slocum
14 Dec 2006, 2:50 PM
I'm not a big fan of attaching JS Objects to DOM Objects. IE is not real happy about it. :)