I just implemented the ActiveAdmin gem with my Rails 3.1 app, and it caused a problem with some javascript I have in my app which allows ajax posting of comments. Removing the active_admin.js file causes the problem to go away. How do I keep the active_admin's javascript while preserving the functionality of my app? Any ideas on what the problems may be?
Contents of active_admin.js:
//= require active_admin/base
Contents of my application.js file:
//= require jquery
//= require jquery_ujs
//= require_tree .
Javascript that is being broken by ActiveAdmin:
jQuery ->
$('.addcomment').live("click", ->
$(this).closest('.comment_area').find('.add_comment_box').parent().removeClass("add_comments_box_hidden").addClass('add_comments_box')
return false )
init_csrf = ->
window._settings.token = $('meta[name="csrf-token"]').attr 'content'
$.ajaxSetup
beforeSend: (xhr) ->
xhr.setRequestHeader "X-CSRF-Token", _settings.token
jQuery ->
$('.post_comment_btn').live("click", ->
$(this).closest('.comment_area').addClass('add_comment_here')
$.post(
'/comments'
$(this).closest('form').serialize()
null
"script"
)
return false )
Link to active_admin github page.