Rails update.js.erb not executing javascript
In your $.ajax
call make sure to set the dataType
option to "script"
otherwise the response could be interpreted in other ways and thus not executed as JS.
Do you work with haml, or html.erb? If the former, then this might be the solution:
respond_to do |format| ... format.js {render layout: false}end
I had the exact same problem, found this question early on, took another hour or so of Googling to find this question on StackOverflow that led me to it: jQuery + Ajax + Haml. js.erb files not firing
In your update.js.erb file you need to escape javascript wherever you execute ruby code.
$('.container').empty().append('<%= escape_javascript( render 'update' )%>')
This is what solved it for me ...