Skip to content

Commit b5d03f8

Browse files
committed
fix double rendering
1 parent 49ba4b5 commit b5d03f8

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

previewers/betatest/js/refiqdacore.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,28 +204,26 @@ function parseData2(data) {
204204

205205
}
206206

207-
// Configure DataTable with conditional columnDefs
207+
// Configure DataTable with conditional columnDefs
208208
let dataTableConfig = {
209209
select: $('#filterby').val() == 'Codes'
210210
};
211211

212212
if (hasColorAttribute) {
213213
dataTableConfig.columnDefs = [
214214
{
215-
// The `data` parameter refers to the data for the cell (defined by the
216-
// `data` option, which defaults to the column being worked with, in
217-
// this case `data: 0`.
218215
"render": function(data, type, row) {
219216
return '<span class="colortile" style="display:block;background-color:' + data + '">&nbsp;</span>';
220217
},
221218
"targets": 2
222219
},
223220
{
224-
// The `data` parameter refers to the data for the cell (defined by the
225-
// `data` option, which defaults to the column being worked with, in
226-
// this case `data: 0`.
227221
"render": function(data, type, row) {
228-
return '<input class="codable" disabled type="checkbox" checked="' + data + '"/>';
222+
// Check if data is already HTML (to avoid double-rendering)
223+
if (type === 'display' && typeof data === 'string' && !data.includes('<input')) {
224+
return '<input class="codable" disabled type="checkbox"' + (data === 'true' ? ' checked' : '') + '/>';
225+
}
226+
return data;
229227
},
230228
"width": "20%",
231229
"targets": 3
@@ -235,10 +233,14 @@ function parseData2(data) {
235233
dataTableConfig.columnDefs = [
236234
{
237235
"render": function(data, type, row) {
238-
return '<input class="codable" disabled type="checkbox" checked="' + data + '"/>';
236+
// Check if data is already HTML (to avoid double-rendering)
237+
if (type === 'display' && typeof data === 'string' && !data.includes('<input')) {
238+
return '<input class="codable" disabled type="checkbox"' + (data === 'true' ? ' checked' : '') + '/>';
239+
}
240+
return data;
239241
},
240242
"width": "20%",
241-
"targets": 2 // Codable is now in column 2 instead of 3
243+
"targets": 2
242244
}
243245
];
244246
}
@@ -541,7 +543,10 @@ $("#filterby")
541543
},
542544
{
543545
"render": function(data, type, row) {
544-
return '<input class="codable" disabled type="checkbox" checked="' + data + '"/>';
546+
if (type === 'display' && typeof data === 'string' && !data.includes('<input')) {
547+
return '<input class="codable" disabled type="checkbox"' + (data === 'true' ? ' checked' : '') + '/>';
548+
}
549+
return data;
545550
},
546551
"width": "20%",
547552
"targets": 3
@@ -551,7 +556,10 @@ $("#filterby")
551556
codeConfig.columnDefs = [
552557
{
553558
"render": function(data, type, row) {
554-
return '<input class="codable" disabled type="checkbox" checked="' + data + '"/>';
559+
if (type === 'display' && typeof data === 'string' && !data.includes('<input')) {
560+
return '<input class="codable" disabled type="checkbox"' + (data === 'true' ? ' checked' : '') + '/>';
561+
}
562+
return data;
555563
},
556564
"width": "20%",
557565
"targets": 2

0 commit comments

Comments
 (0)