Only works after refresh.
Closed this issue · 4 comments
I'm using this along with country_select. You can follow how I configured it here https://coderwall.com/p/1ou6mq. The issue I'm having is that it only loads properly when I hit refresh. I believe using ajax: true
should fix it. But applying this in the second or third hash option does nothing. Is there an onload way of making sure the javascript initializes for this?
I'm using jquery and not prototype.
I believe the problem is caused by Turbolinks.
Have you tried disabling Turbolinks?
I've tried using selective disabling of turbolinks with no success.
data-no-turbolink="true"
The problem occurs because when Turbolinks loads a page, it doesn't dispatch Dom's doument ready.
As described here, you can use the following method to check if a page is fully loaded using both methods (DOM, and Turbolinks):
var ready;
ready = function() {
...your javascript goes here...
};
$(document).ready(ready);
$(document).on('page:load', ready);
You were right about it being turbolinks related. This gem fixed it for me.