Last active
December 21, 2017 14:57
-
-
Save claptimes5/3d5dcfe833eb2c3b8544 to your computer and use it in GitHub Desktop.
Best in place with Noty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Noty - http://ned.im/noty/#/about | |
// Best in place - https://github.com/bernat/best_in_place | |
$(document).on('best_in_place:error', function (event, request, error) { | |
'use strict'; | |
// Display all error messages from server side validation | |
$.each(jQuery.parseJSON(request.responseText), function (index, value) { | |
if (typeof value === "object") { | |
value = index + " " + value.toString(); | |
} | |
noty({ | |
text: value, | |
type: 'error', | |
// If you want a button to dismiss the notification | |
buttons: [ | |
{ | |
addClass: 'btn btn-primary', text: 'Ok', onClick: function ($noty) { | |
$noty.close(); | |
} | |
}] | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment