I wrote some code to generate a custom report which contains, among other things, a couple of dynamic tables. The code seemed to work fine until recently. I think it may be related to a newer version of jQuery library when Knack did the update recently. I also had an issue with a button event, which I was able to resolve. Both the button 'click' event and the dynamic table generation work intermittently now. If anyone can see what the issue may be, I would appreciate it. Here is the relative code for generating the table:
function makeUTLTable(data) {
var utilities = $("<table/>").addClass('howTbl');
var rows = data.length;
var row, r;
console.log("in mut");
console.log(data);
row = $("<tr/>");
row.append($("<th/ class='howCol1'>").text('UTILITIES'));
utilities.append(row);
for (r=0; r<rows; r++) {
row = $("<tr/>");
row.append($("<td/ class='howCol1'>").text(data[r].field_182));
if (data[r].field_94 != "") {
row.append($("<td/ class='howCol2'>").text(data[r].field_94_raw[0].identifier));
row.append($("<td/ class='howCol3'>").text(data[r].field_156_raw.formatted));
}else {
row.append($("<td/ class='howCol2'>").text(""));
row.append($("<td/ class='howCol3'>").text(""));
}
utilities.append(row);
}
console.log(utilities);
return utilities;
}
$(document).on('knack-view-render.view_202', function(event, view, data) {
var temp = makeUTLTable(data);
console.log(temp);
$('#HOWutl').html(temp);
console.dir($('#HOWutl').html());
$('#view_202').hide(); // Hide Detail view
});
I used the 'temp' variable just so I could write it to the console and check it before and after. The problem seems to be getting the HTML into the div.
Thanks for your help.