Created
January 6, 2014 03:44
-
-
Save ascot21/8277888 to your computer and use it in GitHub Desktop.
Inline Editing in ActiveAdmin with Best In Place Gem
This file contains 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
//= require jquery | |
//= require best_in_place | |
//= require jquery.purr | |
//= require active_admin/base | |
$(document).ready(function() { | |
$(".best_in_place").best_in_place() | |
$('.best_in_place').bind("ajax:success", function () {$(this).closest('tr').effect('highlight'); }); | |
$(document).on('best_in_place:error', function(event, request, error) { | |
// Display all error messages from server side validation | |
response = $.parseJSON(request.responseText); | |
$.each(response['errors'], function(index, value) { | |
if(value.length > 0) { | |
if( typeof(value) == "object") {value = index + " " + value.toString(); } | |
var container = $("<span class='flash-error'></span>").html(value); | |
container.purr(); | |
}; | |
}); | |
}); | |
}); |
This file contains 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
gem 'best_in_place' |
This file contains 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
.purr { | |
position: fixed; | |
top: 30px; | |
left: 30px; | |
width: 250px; | |
padding: 15px; | |
background-color: rgba(155,0,0,0.7); | |
border-radius: 5px; | |
z-index: 9999; | |
color: white; | |
&:first-letter { text-transform: uppercase; } | |
} |
This file contains 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
column :position do |i| | |
best_in_place i, :featured, type: :checkbox, path: [:admin, i] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's work ❤️