mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 09:03:49 -07:00
can display server-side errors on the UI.
This commit is contained in:
parent
43baa2b86e
commit
9195dc6de5
7 changed files with 740 additions and 3 deletions
30
UI/jQuery/Validation.js
Normal file
30
UI/jQuery/Validation.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
define(
|
||||
[
|
||||
'jquery'
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
$.fn.addBootstrapError = function (error) {
|
||||
var input = this.find('[name]').filter(function () {
|
||||
return this.name.toLowerCase() === error.propertyName.toLowerCase();
|
||||
});
|
||||
|
||||
var controlGroup = input.parents('.control-group');
|
||||
if (controlGroup.find('.help-inline').length === 0) {
|
||||
controlGroup.find('.controls').append('<span class="help-inline error-message">' + error.errorMessage + '</span>');
|
||||
}
|
||||
|
||||
controlGroup.addClass('error');
|
||||
|
||||
return controlGroup.find('.help-inline').text();
|
||||
};
|
||||
|
||||
|
||||
$.fn.removeBootstrapError = function () {
|
||||
|
||||
this.removeClass('error');
|
||||
|
||||
return this.parents('.control-group').find('.help-inline.error-message').remove();
|
||||
};
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue