好的,所以我有多个同名对象:
<a href="<?php echo Utils::createLink('delete-ms'); ?>&tid=<?php echo $tid; ?>"
class="delete-ms">
<img src="img/status/CANCELED.png" alt="" title="Delete milestone."
class="icon" style="width:18px; height: 18px; margin:0;"/>
</a>
这是对象引用的:
<div id="delete-ms-dialog" title="Delete this milestone?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;">
</span>This milestone will be deleted. Are you sure?</p>
</div>
这是用于调用链接的 JS:
function initDeleteMSDialog() {
var deleteDialog = $('#delete-ms-dialog');
var deleteLink = $('.delete-ms');
deleteDialog.dialog({
autoOpen: false,
modal: true,
width: 476,
buttons: {
'OK': function() {
$(this).dialog('close');
location.href = deleteLink.attr('href');
},
'Cancel': function() {
$(this).dialog('close');
}
}
});
deleteLink.click(function() {
deleteDialog.dialog('open');
return false;
});
}
现在我的问题是多个对象是用同一个类声明的。调用 JS 函数时,它使用类作为链接的来源。我怎样才能得到它,以便 location.href 首先引用我单击以启动对话框的链接?