【发布时间】:2011-10-10 19:48:01
【问题描述】:
我已经尝试了类似标题的问题,但它们不起作用。 (例如:How to load AJAX content into current Colorbox window?)
我有主页:(包括jQuery 1.6.1)
<script type="text/javascript" src="js/jquery.colorbox.js"></script>
<link rel="stylesheet" type="text/css" href="css/colorbox.css" />
<script>
jQuery(function(){
$("#aLink").colorbox();
$('#blub a[rel="open_ajax"]').live('click', function(e){
e.preventDefault();
var url = $(this).attr('href');
$.ajax({
type: 'GET',
url: url,
dataType: 'html',
cache: false,
beforeSend: function() {
//$('#cboxContent').empty();
$('#cboxLoadedContent').empty();
$('#cboxLoadingGraphic').show();
},
complete: function() {
$('#cboxLoadingGraphic').hide();
},
success: function(data) {
$('#cboxLoadedContent').append(data);
}
});
});
});
</script>
<a href="1.html" id="aLink">colorbox open</a>
这很好用,1.html 的(简单)内容已加载到颜色框中:
1.html:
<div id="blub">
<a rel="open_ajax" href="2.html">Change Content</a>
</div>
现在我想通过单击链接来更改内容。这行不通。 以太我得到一个额外的颜色框,或者什么也没有发生。
谢谢!
【问题讨论】:
-
您的意思是当颜色框打开时(内容来自 1.html),它有指向 2.html 的链接?所以基本上,你想要一个颜色框内的链接来更改颜色框的内容。对吗?
-
1.html的内容加载到colorbox中。 “更改内容”链接已经存在。我点击链接...现在我希望将 2.html 的内容加载到现有的颜色框中