Skip to content

Commit bbe2fd3

Browse files
committed
ufTable: make tableElement configurable, and check for existence
1 parent 0e0f291 commit bbe2fd3

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Check if require_email_verification is set in Authenticator and sign-in page (#815)
88
- Factor out hardcoded `sprinkles.json` filename (partially addresses #813)
99
- Add Farsi translations (#816)
10+
- `ufTable`: Make tableElement configurable, and check for existence (#824)
1011
- Put AdminLTE menu toggle button back (Revert e8a26fb and part of a46205f)
1112

1213
## v4.1.13-alpha

app/sprinkles/core/assets/userfrosting/js/uf-table.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
function Plugin (element, options) {
174174
this.element = element[0];
175175
this.$element = $(this.element);
176-
var tableElement = this.$element.find('.tablesorter');
177176

178177
var lateDefaults = {
179178
download: {
@@ -187,6 +186,7 @@
187186
overlay: {
188187
container: this.$element.find('.js-uf-table-overlay')
189188
},
189+
tableElement: this.$element.find('.tablesorter'),
190190
tablesorter: {
191191
widgetOptions: {
192192
columnSelector_container : this.$element.find('.js-uf-table-cs-options'),
@@ -249,6 +249,15 @@
249249

250250
this.settings = $.extend(true, {}, dataAttributeDefaults, this.settings);
251251

252+
// Check that tableElement exists
253+
var tableElement = this.settings.tableElement;
254+
if (!tableElement.length) {
255+
if (window.console && console.error) {
256+
console.error('ufTable could not be initialized: wrapper element does not exist, or does not contain a matched tableElement (see https://learn.userfrosting.com/client-side-code/components/tables )');
257+
}
258+
return;
259+
}
260+
252261
// Copy over dataUrl to pager_ajaxUrl
253262
this.settings.tablesorter.widgetOptions.pager_ajaxUrl = this.settings.dataUrl;
254263

0 commit comments

Comments
 (0)