简体   繁体   English

未捕获的TypeError:Symfony 2中的ExtJS对象原型只能是Object或为null

[英]Uncaught TypeError: Object prototype may only be an Object or null with ExtJS in Symfony 2

I have a list of entity displayed with the Admin-Bundle of Sonata, in Symfony 2. I have override the list to add a custom column that display a map icon by entity. 我在Symfony 2中有一个与Sonata的Admin-Bundle一起显示的实体列表。我已覆盖该列表以添加一个按实体显示地图图标的自定义列。 Then, when someone click on the icon, it displays a pop-up. 然后,当有人单击该图标时,它将显示一个弹出窗口。 The pop-up is constructed by ExJS 4. 弹出窗口由ExJS 4构建。

When my list has only one entity, the pop-up is displaying correctly. 当我的列表中只有一个实体时,弹出窗口将正确显示。

Bu when I have more than one entity (and then x map icon), the pop-up is not displaying anymore and I have this error in console : Bu当我有多个实体(然后是x映射图标)时,弹出窗口不再显示,并且在控制台中出现此错误:

Uncaught TypeError: Object prototype may only be an Object or null 未捕获到的TypeError:对象原型只能是Object或为null

If I have 7 entites, the error is displaying 7 times. 如果我有7个实体,则错误显示7次。

Here's my twig code : 这是我的树枝代码:

{% extends 'SonataAdminBundle:CRUD:base_list_field.html.twig' %}

{% block field%}

{% javascripts '@AAAAdminBundle/Resources/public/js/ExtJS4.2/ext-all-debug.js' %}
<script src="{{ asset_url }}"></script>
<script>
    Ext.Loader.setPath('Ext', '/bundles/aaaadmin/js/ExtJS4.2/src');
</script>
{% endjavascripts %}


{% stylesheets 'bundles/aaaadmin/js/ExtJS4.2/resources/css/ext-all-gray.css' filter='cssrewrite' %}
        <link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}

{% javascripts '@AAAAdminBundle/Resources/public/js/popup.js' %}
     <script src="{{ asset_url }}"></script>
{% endjavascripts %}

<div>
<img src="{{ asset('bundles/aaaadmin/images/map_magnify.png') }}"   
 style="cursor:pointer;"
id="popup-map">
</div>
{% endblock %}

Here's my JS code : 这是我的JS代码:

Ext.require([
'Ext.container.Viewport',
'Ext.window.MessageBox',
'Ext.layout.container.Fit',
]);

Ext.application({
name: 'popup',
launch: function() {
    var popup,
    button = Ext.get('popup-map');
    button.on('click', function(){
        if (!popup) {
            popup = Ext.create('widget.window', {
                title: 'Pop-Up',
                id: 'popup',
                header: {
                    titlePosition: 2,
                    titleAlign: 'center'
                },
                border: false,
                closable: true,
                closeAction: 'hide',
                width: 800,
                minWidth: 400,
                maxWidth: 1200,
                height: 500,
                minHeight: 550,
                maxHeight: 800,
                tools: [{type: 'help'}],
                layout: {
                    type: 'border',
                    padding: 0
                },
                items: [
                    {
                    region: 'center',
                    xtype: 'tabpanel',
                    plain: true,
                    items: [
                        {
                        title: 'Carte',
                        html: 'On mettra la carte ici',
                        border: false,
                        },
                        {
                        title: 'Description',
                        html: 'Attributs de l\'objet sous forme de tableau',
                        border: false,
                        }
                    ]
                    }
                ]
            });
        }
        button.dom.disabled = true;
        if (popup.isVisible()) {
            popup.hide(this, function() {
                button.dom.disabled = false;
            });
        } else {
            popup.show(this, function() {
                button.dom.disabled = false;
            });
        }
});
}
});

Anyone has an idea why ? 有人知道为什么吗?

edit : By looking the source code of the page, it looks like JS file is loaded for each row of the list. 编辑:通过查看页面的源代码,似乎为列表的每一行加载了JS文件。 Maybe the problem is coming from there, and it can explains why it works when there is only one row (and so one load of the JS). 也许问题出在那儿,它可以解释为什么只有一行时(以及JS的一个负载)它工作的原因。

After looking forward, the problem is not coming from my JS code, but by the fact that if I have several entites displayed in a grid, the ext-all-debug.js is loaded the same amount of time there is entites. 在向前看之后,问题不是出自我的JS代码,而是由于如果我在网格中显示了多个实体,那么ext-all-debug.js的加载时间与实体相同。 And then it seems to generate error. 然后似乎会产生错误。

I guess I could move the library to the main template of Sonata. 我想我可以将库移到Sonata的主要模板。 I've tried, there is some bugs but it's working more efficiently. 我试过了,有一些错误,但是工作效率更高。

But then, I guess this is not the correct solution because I don't want to touch to sonata template. 但是,我想这不是正确的解决方案,因为我不想触及奏鸣曲模板。

I'll keep it updated if I find the solution. 如果找到解决方案,我将对其进行更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Extjs Sencha编译的应用程序引发Uncaught TypeError:对象原型只能是Object或null - Extjs sencha compiled app throws Uncaught TypeError: Object prototype may only be an Object or null 未捕获的类型错误:Object 原型可能只是 Object 或 null:未定义 - Uncaught TypeError: Object prototype may only be an Object or null: undefined 未捕获的TypeError:对象原型可能只是一个Object,或者在ember.js上为null - Uncaught TypeError: Object prototype may only be an Object or null on ember.js 未捕获的TypeError:对象原型可能只是一个Object,或者在ember-1.0.0-pre.2上为null - Uncaught TypeError: Object prototype may only be an Object or null on ember-1.0.0-pre.2 TypeError: Object prototype may only be an Object or null: undefined - TypeError: Object prototype may only be an Object or null: undefined 带Typescript抛出TypeError的React Relay(react-relay):对象原型只能是一个Object或为null:未定义 - React Relay (react-relay) with Typescript throwing TypeError: Object prototype may only be an Object or null: undefined 运行dyson模拟服务器(使用express.js)的异常“ TypeError:对象原型只能是对象或为空” - Exception 'TypeError: Object prototype may only be an Object or null' running dyson mock server (using express.js) TypeScript错误对象原型只能是一个对象或null:未定义 - TypeScript Error Object prototype may only be an Object or null: undefined Node.JS对象原型可能只是一个Object,或者使用Redis为null - Node.JS object prototype may only be an Object or null with Redis 未捕获的TypeError:不可变原型对象'#<Object>'不能设置原型 - Uncaught TypeError: Immutable prototype object '#<Object>' cannot have their prototype set
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM