admin管理员组文章数量:1200396
I am trying to open a new colorbox window when one is closed.
I'm using this code:
$(".inline").colorbox({
inline: true,
width: "50%",
escKey: false,
onClose: function() {
$('#newWindow').show();
}
If there anything wrong with this code?
I am trying to open a new colorbox window when one is closed.
I'm using this code:
$(".inline").colorbox({
inline: true,
width: "50%",
escKey: false,
onClose: function() {
$('#newWindow').show();
}
If there anything wrong with this code?
Share Improve this question edited Jan 4, 2012 at 14:27 Rory McCrossan 338k41 gold badges319 silver badges350 bronze badges asked Jan 4, 2012 at 14:25 Satch3000Satch3000 49.4k89 gold badges224 silver badges349 bronze badges 2- Is the missing brace and bracket at the end just a mistake when you copied and pasted? – Rory McCrossan Commented Jan 4, 2012 at 14:28
- If that's all of your code you're missing some closures at the end "})". A little more code and a link would be handy – Alex Commented Jan 4, 2012 at 14:28
3 Answers
Reset to default 18Description
Assuming your using jack moore's colorbox jQuery plugin you have to change onClose
to onClosed
and use open:true
.
And you always have to close the function.
Check out the jsFiddle Demonstration.
Sample
Html
<div class="firstColorBox">first</div>
<div class="secondColorBox">second</div>
jQuery
$(".firstColorBox").colorbox({
inline:true,
width:"50%",
escKey:false,
onClosed:function(){
// open the other colorBox
$(".secondColorBox").colorbox({
inline:true,
width:"50%",
escKey:false,
open:true
});
}
});
More Information
- jsFiddle Demonstration
- jack moore's colorbox jQuery plugin
Update
'onClose' should be 'onClosed'
See the reference here: http://jacklmoore.com/colorbox/
I recommend use the event handlers that come with colorbox:
$(document).one('cbox_closed', function () {
$(".secondColorBox").colorbox({...});
}
This will allow the javascript on the page to run. I was having issues running tags on the second popup and this solved the issue.
The function one will only trigger the event once so you can close the second popup.
本文标签: javascriptColorBox Onclose function not workingStack Overflow
版权声明:本文标题:javascript - ColorBox Onclose function not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738612233a2102697.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论