Skip to content

Instantly share code, notes, and snippets.

@claptimes5
Last active December 21, 2017 14:57
Show Gist options
  • Save claptimes5/3d5dcfe833eb2c3b8544 to your computer and use it in GitHub Desktop.
Save claptimes5/3d5dcfe833eb2c3b8544 to your computer and use it in GitHub Desktop.
Best in place with Noty
// 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