[CLOSED] JavaScript error in IE after loading MultiSelect from Popup

  1. #1

    [CLOSED] JavaScript error in IE after loading MultiSelect from Popup

    When I populate data in my multiselect from an ext.window I get a JavaScript error:

    Can't execute code from a freed script

    When I view the line that the error is called on, I see it's this in this javascript:

       getValue : function (valueField) {
            if (!this.rendered) {
                return this.value || "";
            }
            var returnArray = [],
                selectionsArray = this.view.getSelectedIndexes();
            
            if (selectionsArray.length === 0) { 
                return ''; 
            }
            
            for (var i = 0; i < selectionsArray.length; i++) {
          **this line*** ------>      returnArray.push(this.store.getAt(selectionsArray[i]).get(((valueField != null) ? valueField : this.valueField)));
            }
            
            return returnArray.join(this.delimiter);
        },
    The ext.window populates my multiselect located on the calling page like so:

    function selectRows() { 
    
                var rows = #{gridSelectedRows}.getRowsValues({selectedOnly:false}); 
    
                var ID; 
                var Name; 
    
                for (var i=0; i<rows.length; i++) { 
    
                    userID = rows[i].ID; 
                    dispName = rows[i].Name; 
    
    
                              var ctl = parent.panel.getBody().controlid; 
                    if (!ctl) { ctl = parent.masterTab.activeTab.getBody().ContentPH_panel.getBody().controlid; } 
    
                     ctl.store.add(new Ext.data.Record({text: Name, value: ID })); 
    
                
                        }            
    
                 parent.window.advsearch_window.close(); 
    
                    }
    The error occurs after the multiselect is loaded and I click on one of the rows. This only happens in IE, never in Firefox.
    Last edited by Daniil; Apr 26, 2011 at 2:11 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I don't see that you initialize 'Name' and 'ID' variables which you pass to the 'ctl.store.add' (you initialize userID and dispName only)

    Try to add record by this code
    ctl.store.addRecord({text: dispName, value: userID });
    If it doesn't resolve the issue then please post a sample which we can test locally
  3. #3
    Hi,

    Please investigate
    http://stackoverflow.com/questions/8...a-freed-script

    If you will be in trouble to resolve the issue, please feel free to ask us further posting a simplified code to run and reproduce the issue.
  4. #4
    Quote Originally Posted by Vladimir View Post
    Hi,

    I don't see that you initialize 'Name' and 'ID' variables which you pass to the 'ctl.store.add' (you initialize userID and dispName only)

    Try to add record by this code
    ctl.store.addRecord({text: dispName, value: userID });
    If it doesn't resolve the issue then please post a sample which we can test locally
    Sorry, the real code uses the dispName, userID names, I was just trying to make the code more simplistic for the forum and missed one name change when pasting.
  5. #5

    Sample to reproduce

    Please save these two files into same folder and run in IE:

    The calling page "__popCaller.aspx"

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net Example</title>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
        <ext:XScript ID="XScript1" runat="server">
            
            <script type="text/javascript">
                function searchWindow(pURL) {
    
                    win = new Ext.Window(
    {
        renderTo: Ext.getBody(),
        title: 'Advanced Search',
        height: 600,
        width: 750,
        id: 'advsearch_window',
        border: false,
        modal: false,
        frame: true,
        ctCls: 'windowstyle1',
        closeAction: 'close',
        autoLoad: { mode: 'iframe',
            url: pURL
        }
    });
    
                    win.show();
    
                }
    
            </script>
    
        </ext:XScript>
    </head>
    <body style="padding: 20px;">
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:MultiSelect runat="server" ID="multitest">
        </ext:MultiSelect>
        <ext:Button runat="server" ID="btnSearch" Text="Click to Search">
            <Listeners>
                <Click Handler="searchWindow('__popSearch.aspx')" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
    The window page "__popSearch.aspx"

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.Net Example</title>
         
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
         
         <ext:XScript ID="XScript1" runat="server">
            
            <script type="text/javascript">
                function selectValues() {
    
                    var userID;
                    var dispName;
    
                    for (var i = 0; i < 10; i++) {
    
                        userID = 'username' + i;
                        dispName = 'User Name ' + i;
    
                        parent.multitest.store.add(new Ext.data.Record({ text: dispName, value: userID }));
    
                    }
    
                    parent.advsearch_window.close();
    
                }
            </script>
    
        </ext:XScript>
    </head>
    <body style="padding:20px;">
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
             
             <ext:Button runat="server" ID="test" OnClientClick="selectValues();" Text="Click to Populate Caller"></ext:Button>
        </form>
    </body>
    </html>
    click the button on the calling page to open the window then press the button on the window to populate the calling page multiselect. Then click on an item in the multiselect and have Script debugging turned on so you can see it errors with the error I listed in first message.
  6. #6
    Hi,

    Please add 'parent' to Record constructor
    parent.multitest.store.add(new parent.Ext.data.Record({ text: dispName, value: userID }));
  7. #7
    Quote Originally Posted by Vladimir View Post
    Hi,

    Please add 'parent' to Record constructor
    parent.multitest.store.add(new parent.Ext.data.Record({ text: dispName, value: userID }));
    Great catch. This works and the issue can be closed. Thanks a lot...

Similar Threads

  1. Replies: 8
    Last Post: Jan 27, 2011, 9:33 PM
  2. Javascript Error in IE8 Popup
    By csharpdev in forum 1.x Help
    Replies: 1
    Last Post: Nov 04, 2010, 7:21 AM
  3. [CLOSED] [1.0] Javascript error when loading usercontrol from code
    By klaus.schwarz in forum 1.x Legacy Premium Help
    Replies: 17
    Last Post: Jul 12, 2010, 3:59 PM
  4. [CLOSED] Error loading page using Javascript
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 25, 2010, 2:14 PM
  5. [CLOSED] JavaScript error with MultiSelect inside BorderLayout and TabPanel
    By martin.mosimann in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 25, 2009, 1:03 PM

Posting Permissions