cagegory_select_box.js.coffee
jQuery ($) ->
showAjaxErrorMessage = ->
alert('error message')
$(document).delegate('.book_category_id','change', ->
$('.book_category_id').val($(this).val())
$('.category_select_box').submit()
$.ajax
beforeSend: ->
#それっぽいcssを用意しておいて、アイコンにクラスを追加する
icon = $('.category_select_box').find('.static-icon')
icon.addClass('loading-spin')
success: ->
#アイコンからクラスを取り除く
icon = $('.category_select_box').find('.static-icon')
icon.removeClass('loading-spin')
error: -> showAjaxErrorMessage
)
ajaxのevent一覧はここで確認出来る
http://api.jquery.com/Ajax_Events/