问题
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