jQuery + Fancybox trigger error on Internet Explorer 8

放肆的年华 提交于 2019-12-14 01:47:47

问题


I have this jQuery code on my page that works fine in Chrome, but I get and error on Internet Explorer 8 in the trigger('click') line

$('#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
});

This is my html for fancybox:

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

I clicked in a butten and I insert some data throught ajax in the database, after that I want to open a fancybox. Like I said, it works on Chrome but not in IE8

any help or clue? thanks in advance


回答1:


Off the top of my head, two possibilites:

1) 'titleShow' : true, <-- extra comma at the end of object IE interprets as Satan

2) Enclose your event handler in a document ready block:

$(document).ready(function () {
    $('#btnd16').click(function (e) {
    ...
});


来源:https://stackoverflow.com/questions/10140344/jquery-fancybox-trigger-error-on-internet-explorer-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!