|
101 | 101 | addParams : {}, |
102 | 102 | filterAllField : '_all', |
103 | 103 | useLoadingTransition : true, |
104 | | - rowTemplateSelector : null, |
| 104 | + rowTemplate : null, |
105 | 105 | tablesorter : { |
106 | 106 | debug: false, |
107 | 107 | theme : 'bootstrap', |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 |
|
| 294 | + // Locate and compile row template |
| 295 | + this.rowTemplate = Handlebars.compile('<tr>'); |
| 296 | + // If rowTemplateSelector is set, then find the DOM element that it references, which contains the template |
| 297 | + if (this.settings.rowTemplate) { |
| 298 | + var rowTemplate = this.settings.rowTemplate; |
| 299 | + if (typeof rowTemplate === 'string') { |
| 300 | + this.rowTemplate = Handlebars.compile($(this.settings.rowTemplate).html()); |
| 301 | + } else { |
| 302 | + this.rowTemplate = rowTemplate; |
| 303 | + } |
| 304 | + } |
| 305 | + |
294 | 306 | // Link CSV download button |
295 | 307 | this.settings.downloadButton.on('click', this.settings.onDownload); |
296 | 308 |
|
|
421 | 433 | if (data) { |
422 | 434 | var size = data.rows.length; |
423 | 435 |
|
424 | | - var rowTemplate = Handlebars.compile('<tr>'); |
425 | | - // If rowTemplateSelector is set, then find the DOM element that it references, which contains the template |
426 | | - if (this.settings.rowTemplateSelector) { |
427 | | - rowTemplate = Handlebars.compile($(this.settings.rowTemplateSelector).html()); |
428 | | - } |
429 | | - |
430 | 436 | // Render table rows and cells via Handlebars |
431 | 437 | for (var row = 0; row < size; row++) { |
432 | 438 | var cellData = { |
|
435 | 441 | site : site |
436 | 442 | }; |
437 | 443 |
|
438 | | - rows += rowTemplate(cellData); |
| 444 | + rows += this.rowTemplate(cellData); |
439 | 445 |
|
440 | 446 | for (var col = 0; col < this.columnTemplates.length; col++) { |
441 | 447 | rows += this.columnTemplates[col](cellData); |
|
0 commit comments