繁体   English   中英

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

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

我在Symfony 2中有一个与Sonata的Admin-Bundle一起显示的实体列表。我已覆盖该列表以添加一个按实体显示地图图标的自定义列。 然后,当有人单击该图标时,它将显示一个弹出窗口。 弹出窗口由ExJS 4构建。

当我的列表中只有一个实体时,弹出窗口将正确显示。

Bu当我有多个实体(然后是x映射图标)时,弹出窗口不再显示,并且在控制台中出现此错误:

未捕获到的TypeError:对象原型只能是Object或为null

如果我有7个实体,则错误显示7次。

这是我的树枝代码:

{% 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 %}

这是我的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;
            });
        }
});
}
});

有人知道为什么吗?

编辑:通过查看页面的源代码,似乎为列表的每一行加载了JS文件。 也许问题出在那儿,它可以解释为什么只有一行时(以及JS的一个负载)它工作的原因。

在向前看之后,问题不是出自我的JS代码,而是由于如果我在网格中显示了多个实体,那么ext-all-debug.js的加载时间与实体相同。 然后似乎会产生错误。

我想我可以将库移到Sonata的主要模板。 我试过了,有一些错误,但是工作效率更高。

但是,我想这不是正确的解决方案,因为我不想触及奏鸣曲模板。

如果找到解决方案,我将对其进行更新。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM