Im having a hard time getting my Javascript to function without placing it within script tags. If I place it within the asset pipeline it will only work on the initial page load.
For example if im using UJ to append a menu to the page, it will be exempt from the pipeline JS.
ready = ->
alert "page loaded"
$('a').click ->
alert "link clicked"
$(document).ready(ready)
$(document).on('page:load', ready)
This example above gives me the "page loaded" message at DOM ready, and the "link clicked" function will only fire for links which are on the page when it initially loads. If I use UJ to append another menu with links, clicking on the new links will not trigger the "link clicked" function. Its important to note that the links Im talking about have "remote: true" enabled.
If I place the raw JS form of the above script within script tags on the page it works fine for all links clicked.
Im wondering: how do use JS to control content which is appended after the initial DOM ready event?