3

我的页面上有这个 jQuery 代码,它在 Chrome 中运行良好,但在 Internet Explorer 8 的 trigger('click') 行中出现错误

$('#btnd16').click(function(e){
    var iiid = $('#midet').val();
    $('#d16_midethistorial_id').val(iiid);

    //sumamos por ajax
    var $mivalor = $('#d16_midethistorial_id').val() 
    var $url = $('input#miruta').val(); 

    $.post($url, { midethistorial_id: $mivalor }, 
        function(data) { 
                $("#nirefancy").fancybox({
                'width'         : '90%',
                'height'    : '90%',
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic',
                'type'      :'inline',
                'autoDimensions': false,
                'autoScale' : false,
                        'scrolling' : 'no',
                'titleShow' : true,
            }).trigger('click');
    });

    return false
});

这是我的fancybox html:

<a href="{{ path('detformacion_play',{'id': detentrenamiento.detformacion.id }) }}"  id="nirefancy" style="display: none;">.</a>

我单击了一个按钮,然后通过 ajax 在数据库中插入了一些数据,之后我想打开一个花式框。就像我说的,它适用于 Chrome,但不适用于 IE8

任何帮助或线索?提前致谢

4

1 回答 1

5

在我的脑海中,有两个可能性:

1) 'titleShow' : true,<-- 对象末尾的额外逗号 IE 解释为撒旦

2)将您的事件处理程序包含在文档就绪块中:

$(document).ready(function () {
    $('#btnd16').click(function (e) {
    ...
});
于 2012-04-13T12:00:16.037 回答