Edward Tanguay
Edward Tanguay

Reputation: 193312

Why am I getting errors in ext-all-debug.js in lines 4236 - 4242?

I've developed a PHP framework that generates ExtJS code in the form of an application.

This involves building the full ExtJS object literal on the first call, e.g.:

Ext.onReady(function(){
    menuItemStart = new Ext.Panel({
        id: 'panelStart',
        title: 'Start',
        html: 'This is the start menu item.',
        cls:'menuItem'
    });
    ...

and then navigation in the application consists of event handlers which load PHP files via AJAX that output ExtJS code, and then execute this code with this function:

function loadViewViaAjax(url, paramTargetRegion) {
    Ext.Ajax.request({
        url: url,
        success: function(objServerResponse) {
            var responseText = objServerResponse.responseText;
            var scripts, scriptsFinder=/<script[^>]*>([\s\S]+)<\/script>/gi;
            while(scripts=scriptsFinder.exec(responseText)) {
                eval(scripts[1]);
            }
        }
    });
}

This works well. However, I now have this situation where when a page is loaded from PHP instead of via a triggered ExtJS event handler, I get errors that are varied but all come from one block of code in the ext-all-debug.js file, namely in line 4236 and line 4242:

enter image description here

Has anyone experienced anything similar or know what could be causing this?

Addendum

Yes @ChrisR, here is an error I can reproduce on my machine:

enter image description here

It says it is getting the error in the fourth line of this code, but if I click on it, it takes me to line 4242 shown above in the ExtJS library code.

<script type="text/javascript">
    clearExtjsComponent(targetRegion);
    var panel_form = new Ext.FormPanel({
        labelWidth: 100,
        frame:true,
        style: 'margin: 10px',
        title: 'Test Product (TEST PAGE 2)',
        bodyStyle:'padding:5px 5px 0',
        width: 500,
        defaultType: 'textfield',

        items: [{
                fieldLabel: 'ID',
                value: "111",
                name: 'id',
                width: 370,
                hidden: false,
                style: 'text-align: right',
                name: 'id',
                width: 50,
                hidden: false,
            },{
                fieldLabel: 'Product',
                value: "Paper",
                xtype: 'displayfield',
                name: 'product',
                width: 370,
                hidden: false,
            },{
                fieldLabel: 'Label',
                value: "none",
                name: 'product3',
                width: 370,
                hidden: false,
            },{
                fieldLabel: 'Label',
                value: "first line\<br/>second line\<br/>third line",
                xtype: 'displayfield',
                height: 100,
                xtype: 'displayfield',
                name: 'product4',
                width: 370,
                hidden: false,
            }
        ],

        buttons: [{
                text: 'Save',
                handler: function() {
                    if(panel_form.getForm().isValid()){
                        panel_form.getForm().getEl().dom.action = 'backend/application/help/test';
                        panel_form.getForm().getEl().dom.method = 'POST';
                        panel_form.getForm().submit({
                            success : function(form, action) {
                    replace_region_with_uri_content('backend/modules');
                            }
                        })
                    } else {
                        Ext.Msg.minWidth = 360;
                        Ext.Msg.alert('Invalid Form', 'Some fields are invalid, please correct.');
                    }
                }
            },{
                text: 'Cancel',
                handler: function(){
                    replace_region_with_uri_content('backend/modules');
                }
            }]
    });
    replaceComponentContent(targetRegion, panel_form);

    hideComponent(regionHelp);
</script>

Upvotes: 0

Views: 1303

Answers (1)

Brian Moeskau
Brian Moeskau

Reputation: 20429

Is this on IE? If so, all the trailing commas in your code may be the issue (they certainly are an issue). Also, lots of duplicate configs in your first item. Try running JSLint on your code from time to time to catch stuff like that.

Upvotes: 2

Related Questions