原谅大块的代码,但我被困住了,并且真的被烧毁......
所以我正在加载一些内容,然后显示一个Dialog。根据你按哪个按钮我做了几件事。我的不一致似乎是在“保存计划”和“取消发送”块之间
这两个块中的代码相同
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未定义,因此拆分正在爆炸。
谁能告诉我,我做错了什么?
$("#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();
}
});
});
答案 0 :(得分:0)
尝试使用$(table).find
替换下面的table.find
(因为您已经宣布table = $("#tblSchedule")
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});
});
此外,如果您尝试从tr
中选择每个$("#tblSchedule")
,$("#tblSchedule").find("tr")
可能是更好的选择器。