我最近沒有這證實了我的CMS刪除鏈接。首先,你應該實例化一個對話框窗口(這是如此,如果你在對話框中單擊關閉,然後再次打開它,它顯示了...否則,它破壞了):
$(document).ready(function()
{
/**
* Create a dialog box for confirming deletes.
* This creates the box at domready. The box is opened
* by a call to dialog("open") in the delete link.
*/
$("#delete-dialog").dialog({
autoOpen : false,
bgiframe : true,
buttons : {
"Yes, I'm sure" : function()
{
$(this).dialog("close");
var href = $(this).dialog("option", "href");
var row = $(this).dialog("option", "row");
$.doDelete(href, row);
},
"Cancel" : function()
{
$(this).dialog("close");
}
},
height : 150,
modal : true,
overlay : {
backgroundColor : "#000000",
opacity : 0.75
},
resizable : false
});
});
然後「掛鉤」的一標籤(仍處於的document.ready塊):
/**
* Make all delete links confirm before sending to delete path.
*/
$("a.delete-href").live("click", function(event)
{
event.preventDefault();
var href = $(this).attr("href");
var row = $(this).parent().parent();
// pass some custom options to the dialog
$("#delete-dialog").dialog("option", "href", href);
$("#delete-dialog").dialog("option", "row", row);
// open the previously init'ed dialog
$("#delete-dialog").dialog("open");
});
是否存在#To和#To之間的差異? – leora 2009-08-25 14:28:01
如果您正確使用id屬性(即* once *),則沒有區別(並且#To理論上更快,因爲它不會進行tagName檢查)。 – 2009-08-25 14:52:10
有沒有區別。在無效文檔中,可能有兩個元素共享相同的ID,這是UB(我認爲)。如果標籤名稱和標識檢查已完成,並且這兩個元素具有不同的標籤名稱,則假設jQuery不會忽略選擇器中的標籤名稱,您可能會得到不同的結果。 – strager 2009-11-12 00:28:45