This is a Rails 5 adaptation of an answer to a StackOverflow question regarding using jQuery UJS to display AJAX-retrieved content in a modal. Here is the original answer:
http://stackoverflow.com/questions/5766055/jquery-modal-windows-and-edit-object/5766232#5766232
Aha. The answer is that Rails'
rails.js
doesn't triggerajax:success
if the response to the ajax request isn'ttext/json
. This meant I had to adjust my controller to respond properly, fromto
...and then alter
modals.js.coffee
to use.html(data.html)
instead of just.html(data)
.