jQuery id is undefined in one block but not the other? -
forgive big block of code stuck , getting burned out on this...
so loading content , displaying dialog. depending upon button press several things. inconsistancies seem between save schedule , cancel send blocks
this code same in both blocks
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");
however in cancel send block id undefined , hence split blowing up.
can tell mw doing wrong please?
$("#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 = $(this); var table = $("#tblschedule"); var parameterarray = []; //loop each row of schedule table 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 @ to the lowest degree 1 item schedule"); } }, 'cancel send': function() { if(confirm("are sure want cancel entire send?")) { var = $(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(); } }); });
try replacing $(table).find
below table.find
(since you've declared 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}); });
also, if you're trying select each tr
$("#tblschedule")
, $("#tblschedule").find("tr")
may improve selector.
jquery
No comments:
Post a Comment