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
Really jazzed that you ran through all this on S.O. and here; it gets me about 95% there on my current feature. I'm getting stuck on one thing, which I think might be a Rails 3.2.x issue (where you have a 3.1.x adaptation here). I'm getting errors loading the modal.js.coffee file; in the console, the error is "Uncaught TypeError: Object function (e,t){return new v.fn.init(e,t,n)} has no method 'on' ". The Object in question is jQuery itself. Comments on this S.O. question made me question if it was a jQuery version incompatibility. I'm fiddling with it (ha) here to try and debug, and I'll ask on S.O. as well, but I'm commenting here in case you have feedback.