$(document).on('turbolinks:load', function() {
$('.box').on("click", function() {
alert('hello')
});
});
This does not work on elements with class box that are appended with ajax. It only works on the elements that are present on the initial loading of the page. I have also tried as wrappers:
$(document).ready(function() { });
and
var helloscript = function() { };
but nothing works.
You may call it like:
$(document).on('click', '.box', function (event) {
});