1. #1
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    Thinka is on a distinguished road

      0  

    Default Javascript function in updateManager returned content

    Javascript function in updateManager returned content


    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.

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    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.

  3. #3
    Ext User
    Join Date
    Mar 2007
    Posts
    5
    Vote Rating
    0
    Thinka is on a distinguished road

      0  

    Default


    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.

  4. #4
    Ext User
    Join Date
    Mar 2007
    Location
    Boston
    Posts
    349
    Vote Rating
    0
    sjivan is on a distinguished road

      0  

    Default


    Quote Originally Posted by jacksloc
    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.
    Code:
    window[objName] = eval(objName);
    should do it. We do this in AjaxAnywhere.

    Sanjiv

  5. #5
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    I'm not a big fan of attaching JS Objects to DOM Objects. IE is not real happy about it.

Similar Threads

  1. UpdateManager.update() duplicates header content
    By thejoker101 in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 29 Mar 2007, 12:39 PM
  2. updateManager and callback function
    By martin in forum Ext 1.x: Help & Discussion
    Replies: 5
    Last Post: 10 Jan 2007, 7:01 PM
  3. Javascript basics - variable from nested function?
    By angusf in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 17 Dec 2006, 3:35 PM
  4. YAHOO.ext.UpdateManager setting Content-Type for ISO-8859
    By young_matthewd in forum Ext 1.x: Help & Discussion
    Replies: 3
    Last Post: 14 Nov 2006, 11:32 AM
  5. tabpanel content and javascript
    By jbowman in forum Ext 1.x: Help & Discussion
    Replies: 8
    Last Post: 12 Sep 2006, 7:43 PM

Thread Participants: 2