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