Jquery加载单击的链接(如果从对话框中确认)
我有这个jquery代码:Jquery加载单击的链接(如果从对话框中确认),jquery,jquery-ui-dialog,Jquery,Jquery Ui Dialog,我有这个jquery代码: $("#deletec-box").dialog({ autoOpen:false, resizable:false, height:230, modal:true, buttons:{ "Confirm":function(){ window.location=$("a[id*='deletec-confirm']").attr('href'); $(th
$("#deletec-box").dialog({
autoOpen:false,
resizable:false,
height:230,
modal:true,
buttons:{
"Confirm":function(){
window.location=$("a[id*='deletec-confirm']").attr('href');
$(this).dialog("close");
},Cancel:function(){
$(this).dialog("close");
}
}
});
$("a[id*='deletec-confirm']").click(function(){
$("#deletec-box").dialog("open");
return false;
});
在网页中,我有:
<a href="?action=delc&cid=2" id="deletec-confirm2" title="Delete This Record">Delete</a>
<a href="?action=delc&cid=3" id="deletec-confirm3" title="Delete This Record">Delete</a>
单击上面的第二个链接时,它将使用第一个链接url加载。如何让jquery对话框根据上面单击的链接获得正确的url?我只想做的是,如果他们单击要求确认的删除链接,如果他们单击对话框中的确认按钮,我希望他们最初单击的url继续。我有两个建议:
这里的想法是将适当的信息存储在已知位置,并在对话框中使用这些信息。例如:
$("#deletec-box").dialog({
autoOpen:false,
resizable:false,
height:230,
modal:true,
buttons:{
"Confirm":function(){
window.location=$('#deletec-box').data('loc');
$(this).dialog("close");
},Cancel:function(){
$(this).dialog("close");
}
}
});
$("a[id*='deletec-confirm']").click(function(){
$('#deletec-box').data('loc', $(this).attr('href'));
$("#deletec-box").dialog("open");
return false;
});
$("#deletec-box").dialog({
autoOpen:false,
resizable:false,
height:230,
modal:true,
});
$("a[id*='deletec-confirm']").click(function(){
loc = $(this).attr('href');
$('#deletec-box').dialog({
buttons:{
"Confirm":function(){
window.location=loc;
$(this).dialog("close");
},Cancel:function(){
$(this).dialog("close");
}
}
});
$("#deletec-box").dialog("open");
return false;
});