I know there is a lot of topics with this questions, but I don't found the answer to my particular question ...
Refer to the FAQ, we had to use one of these to close the fancybox.
$.fancybox.close();
or
parent.$.fancybox.close();
But this doesn't work in my case.
I use an 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 the click on a button, it shows another page in the fancybox. In this page there is a button with the following code :
<input type=button onclick="$.fancybox.close();" value="Save" style="margin-top:30px;" class=button>
I know there is a lot of topics with this questions, but I don't found the answer to my particular question ...
Refer to the FAQ, we had to use one of these to close the fancybox.
$.fancybox.close();
or
parent.$.fancybox.close();
But this doesn't work in my case.
I use an 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 the click on a button, it shows another page in the fancybox. In this page there is a button with the following code :
<input type=button onclick="$.fancybox.close();" value="Save" style="margin-top:30px;" class=button>
Share
Improve this question
edited Mar 17, 2016 at 2:14
Jason
2,3042 gold badges19 silver badges25 bronze badges
asked Apr 1, 2015 at 7:34
Europlis LogistiqueEuroplis Logistique
211 silver badge3 bronze badges
4
- Can you try $.fn.fancybox.close() on click event.? – Hardeep Randhawa Commented Apr 1, 2015 at 7:51
- I tried it too but the console returns me : TypeError: $.fn.fancybox.close is not a function – Europlis Logistique Commented Apr 1, 2015 at 7:57
- $.fn.fancybox.close() doesn't work for version 2.x, in fact, it raises an error. If you're using version 2.x, try $.fancybox.close(true) instead. – Hardeep Randhawa Commented Apr 1, 2015 at 8:13
- Yes I'm using version 2.1.5, I tried $.fancybox.close(true); and same result ... I tried to use this with the xAqweRx's method and same result again >< – Europlis Logistique Commented Apr 1, 2015 at 8:22
1 Answer
Reset to default 3Your onclick="$.fancybox.close();"
doesn't see your main fancybox object.
Try to do something like this
<input type="button" value="Save" style="margin-top:30px;" class="button closeFancybox">
And in your main document
$(function(){
$(document).on('click','.closeFancybox',function(){
$.fancybox.close();
})
})
Update
Please try to simulate similar behaviour on https://jsfiddle I've tried example that you've wrote and it worked.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745341762a4623358.html
评论列表(0条)