Why don't you just put your javascript code in the generated response from "/fault_books/" + <%= @fault_book.id %>"
In this case, just do it as usual:
$(document).ready(function(){ var module = $(".module-logo")
And nothing needs to be done when opening a new window, just call:
popup = window.open("/fault_books/" + <%= @fault_book.id %> , "popup");
This solution is simple and easier to maintain, since the scripts are self-contained. Scripts on the page perform tasks only for the content page. Say if you have another page that opens the same URL window.open("/fault_books/" + <%= @fault_book.id %> , "popup"); . You do not need to duplicate the code.
source share