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
Hey @pjmorse — glad this has helped so many people! I saw the problem you had on StackOverflow and it looks like someone has identified the issue. I've updated the Gist code to resolve that issue, too. Thanks for calling attention to it!