javascript - How to close Fancybox from a button click? -
i know there lot of topics questions, don't found answer particular question ...
refer faq, had use 1 of these close fancybox.
$.fancybox.close();
or
parent.$.fancybox.close();
but doesn't work in case.
i use ajax type of fancybox, see below :
$('.fancybox2').fancybox({ type: 'ajax', title: 'admin', maxwidth : 800, maxheight : 400, fittoview : false, width : '70%', height : '70%', autosize : false, closeclick : false, openeffect : 'elastic', closeeffect : 'none', });
so after click on button, shows page in fancybox. in page there button following code :
<input type=button onclick="$.fancybox.close();" value="save" style="margin-top:30px;" class=button>
your onclick="$.fancybox.close();"
doesn't see main fancybox object. try this
<input type="button" value="save" style="margin-top:30px;" class="button closefancybox">
and in main document
$(function(){ $(document).on('click','.closefancybox',function(){ $.fancybox.close(); }) })
update
please try simulate similar behaviour on https://jsfiddle.net i've tried example you've wrote , worked.
Comments
Post a Comment