$(document).ready(function(){
// When the modal gets opened
$('#main').on('show.bs.modal', function(){
// We remove any event with off(), then, we use the 'load' event
$('iframe.wrapper').off().load(function(){
// After iframe contents FULL loading, we get its height
var b = $('iframe.wrapper').contents().find('body')
var h = b.height();
console.log(b, h);
// And we assign it to iframe's parent, then we can show it again
$('iframe.wrapper').parent().css('height', h+'px').css('opacity', 1);
});
// We hide the iframe's parent element and we set the new source
$('iframe.wrapper').parent().css('opacity', 0);
$('iframe.wrapper').attr('src', '/iframe/ZlDdz');
});
// When the element is clicked
$('h2').on('click', function(){
$('#main').modal('show');
return false;
});
});