如何打开具有特定 ID 或类的彩盒
How to open a colorbox with specific Id or class?
我有以下代码:
<div class="hidden">
<div id="deletePopContent" class="c-popup">
<h2 class="c-popup-header">Delete Practice Sheet</h2>
<div class="c-content">
<h3>Are you sure to delete this practice sheet?</h3>
<p class="alert"><strong>You are about to perform an action which can't be undone</strong></p>
<a href="#"class="c-btn">No</a><a href="#"class="c-btn" id="delete_url">Delete</a>
</div>
</div>
</div>
$(document).ready(function(){
$(document).on('click', '.edit_user_transaction_status', function (e) {
e.preventDefault();
$.colorbox.close();
//for confirmation that status change
var ans=confirm("Are you sure to change status?");
if(!ans) {
return false;
}
var post_url = $(this).attr('value');
var transaction_status_update = $('#transaction_status_update').val();
$.ajax({
type: "POST",
url: post_url+"&transaction_status_update="+transaction_status_update,
data:$('#transaction_form').serialize(),
dataType: 'json',
success: function(data) {
var error = data.login_error;
$(".ui-widget-content").dialog("close");
//This variables use for display title and success massage of transaction update
var dialog_title = data.title;
var dialog_message = data.success_massage;
//This get link where want to rerdirect
var redirect_link = data.href;
alert(redirect_link);
/*var $dialog = $("<div class='ui-state-success'></div>")
.html("<p class='ui-state-error-success'>"+dialog_message+"</p>")
.dialog({
autoOpen: false,
modal:true,
title: dialog_title,
width: 500,
height: 80,
close: function(){
document.location.href =redirect_link;
}
});*/
/*$dialog.dialog('open');*/
document.location.href =redirect_link;
$.colorbox({inline:true, width:666});
}
});
});
});
你需要使用href
属性,比如:
$.colorbox({
inline:true,
href: "#deletePopContent",
width:666
});
您正在通过以下方式重定向:
document.location.href =redirect_link; <-- remove this
$.colorbox({inline:true, width:666, href: "#deletePopContent"});
所以只需删除它,它应该可以工作
您可以使用 Colorbox onClosed
事件,以便在关闭 ColorBPX 弹出窗口后重定向,如下所示:
$.colorbox({
inline:true,
href: "#deletePopContent",
width:666,
onClosed: function() {
window.location.href = redirect_link;
}
});
相关文章:
- 获取打开jquery对话框的button的id
- 无法调用方法“”;getEditResponseUrl"当使用表单ID打开表单时,绑定到工作表的Google
- 在新窗口上打开Javascript Id
- 如何获得点击的元素'id并在jquery中打开一个弹出窗口
- 我如何在PhantomJS只知道弹出id的情况下打开弹出窗口
- 手风琴菜单 JQuery - 如何打开特定的“id”
- 多个按钮打开相同的操作,但不同的 ID 容器
- IE 窗口.在第二个会话时打开 打开一个具有第一个会话 ID 的窗口
- 打开没有 ID 的预先存在的实体
- Jquery 选项卡使 url 中的子 ID 选项卡保持打开状态
- 在由 window.open 打开的窗口中滚动到没有 ID 的元素
- 从经过身份验证的用户获取打开图形操作 ID
- 如何打开具有特定 ID 或类的彩盒
- 打开新选项卡函数对按钮 ID 不起作用
- 基于id打开jquery对话框
- 在打开的ID上发送用户/传递帖子
- 如何为新打开的窗口设置ID
- 如何使用Javascript在页面刷新时按ID打开特定选项卡
- 通过Javascript从表单传递一个变量id来打开一个新的file.html
- 在jquery中使用不同的ID自动打开弹出框