mirror of https://github.com/ColorlibHQ/AdminLTE
add errorhandling to cardrefresh plugin (#3555)
Co-authored-by: REJack <info@rejack.de> Co-authored-by: Daniel <50356015+danny007in@users.noreply.github.com>pull/3646/head
parent
bd372c0904
commit
a7e0650821
|
@ -58,7 +58,7 @@
|
|||
},
|
||||
{
|
||||
"path": "./dist/js/adminlte.js",
|
||||
"maxSize": "15.7 kB"
|
||||
"maxSize": "16.1 kB"
|
||||
},
|
||||
{
|
||||
"path": "./dist/js/adminlte.min.js",
|
||||
|
|
|
@ -34,12 +34,15 @@ const Default = {
|
|||
content: '.card-body',
|
||||
loadInContent: true,
|
||||
loadOnInit: true,
|
||||
loadErrorTemplate: true,
|
||||
responseType: '',
|
||||
overlayTemplate: '<div class="overlay"><i class="fas fa-2x fa-sync-alt fa-spin"></i></div>',
|
||||
errorTemplate: '<span class="text-danger"></span>',
|
||||
onLoadStart() {},
|
||||
onLoadDone(response) {
|
||||
return response
|
||||
}
|
||||
},
|
||||
onLoadFail(_jqXHR, _textStatus, _errorThrown) {}
|
||||
}
|
||||
|
||||
class CardRefresh {
|
||||
|
@ -74,6 +77,16 @@ class CardRefresh {
|
|||
this._settings.onLoadDone.call($(this), response)
|
||||
this._removeOverlay()
|
||||
}, this._settings.responseType !== '' && this._settings.responseType)
|
||||
.fail((jqXHR, textStatus, errorThrown) => {
|
||||
this._removeOverlay()
|
||||
|
||||
if (this._settings.loadErrorTemplate) {
|
||||
const msg = $(this._settings.errorTemplate).text(errorThrown)
|
||||
this._parent.find(this._settings.content).empty().append(msg)
|
||||
}
|
||||
|
||||
this._settings.onLoadFail.call($(this), jqXHR, textStatus, errorThrown)
|
||||
})
|
||||
|
||||
$(this._element).trigger($.Event(EVENT_LOADED))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue