0
原諒大塊的代碼,但我被卡住,真的被燒燬在這...jQuery id在一個塊中未定義,但不是另一個?
所以我加載一些內容,然後顯示一個對話框。根據你按哪個按鈕,我做了幾件事。我inconsistancies似乎是保存計劃之間和取消發送塊
此代碼是相同的兩個塊
var dt = $(this).find("input[type=text]").val();
var id = $(this).find("input[type=text]").attr("id");
var CustomObjectKey = id.split("_")[1];
var alt = $(this).find("input[type=text]").attr("alt");
然而,在取消發送塊的ID是不確定的,因此,拆分吹起來。
任何人都可以告訴mw我做錯了嗎?
$("#ActionContainer").load(wsUrl, { Function:"BuildScheduleDialog", ArticleID:ArticleID}, function(){
var Subject = $(this).find("#hdnSubject").val();
$("#ActionContainer").dialog({
title: "Edit Schedule: " + ArticleTitle,
height: 'auto',
width: 'auto',
modal: true,
buttons: {
'Cancel': function() {
$(this).dialog('close');
},
'Save Schedule': function() {
var that = $(this);
var table = $("#tblSchedule");
var parameterArray = [];
//loop each row of the Schedule table to get the parameters
$(table).find("tbody>tr").not(':first').each(function() {
var dt = $(this).find("input[type=text]").val();
var id = $(this).find("input[type=text]").attr("id");
var CustomObjectKey = id.split("_")[1];
var alt = $(this).find("input[type=text]").attr("alt");
//alert(dt + " " + id + " " + CustomObjectKey + " " + alt);
if(dt != "" && alt === "")
{
parameterArray.push({Region: $(this).find("#spRegion").text(), Date: dt, ArticleTitle: ArticleTitle ,ArticleID: ArticleID, PublicationTypeID: PublicationTypeID, CustomObjectKey: CustomObjectKey, Subject: Subject});
}
});
if(parameterArray.length > 0)
{
ShowWaitIcon();
$("#results").load(wsUrl, { Function:"Schedule", Action: "Edit", Items: JSON.stringify(parameterArray)}, function(){
$("#results").fadeIn(1000);
$('#results').delay(3000).fadeOut(3000);
$(that).dialog('close');
LoadMainTable();
});
}
else
{
alert("Please select at least one Item to Schedule");
}
},
'Cancel Send': function() {
if(confirm("Are you sure you want to cancel this entire send?"))
{
var that = $(this);
var table = $("#tblSchedule");
var parameterArray = [];
var status = "";
$(table).find("tbody>tr").each(function() {
var dt = $(this).find("input[type=text]").val();
var id = $(this).find("input[type=text]").attr("id");
var CustomObjectKey = id.split("_")[1];
var alt = $(this).find("input[type=text]").attr("alt");
parameterArray.push({Region: $(this).find("span").text(), Date: dt, ArticleTitle: ArticleTitle ,ArticleID: ArticleID, PublicationTypeID: PublicationTypeID, CustomObjectKey:CustomObjectKey});
});
/*ShowWaitIcon();
$("#results").load(wsUrl, { Function:"CancelAllSchedule", Items: JSON.stringify(parameterArray)}, function(){
$("#results").fadeIn(1000);
$('#results').delay(3000).fadeOut(3000);
$(that).dialog('close');
LoadMainTable();
});
*/}
}
},open: function(event, ui){
$(".datePicker", "#ActionContainer").datetimepicker({
timeFormat: 'hh:mm tt',
showTimezone: true
});
BindCheckboxes();
}
});
});
最好寫一個函數,而不是複製粘貼代碼 – Popnoodles