ruby on rails - How to fire CoffeeScript/Javascript after user presses back button -
different parts of ui on rails 4 application rely on dynamically populated select controls, option selected in first select determines options available in second select. script sets options of second select runs when select's onchange event fired.
everything works fine, until user clicks browser's button , returns form contains 2 select controls. first select retains user's selection, second select (which dynamically populated script) reverts default options.
browsers don't seem fire event @ when user uses button, there doesn't appear me hang script on. how can script run after user presses button?
what alternatives if can't actual script run? have ditch dynamic selects in favor of single, massive select lists options in 1 control?
this inelegant, expedient solution:
rather recreating own session history mechanism, added javascript_tag
form included copy of script runs on page load (including when user hits button, whereas script in assets folder ran when page newly loaded).
this solution isn't dry means, works in limited circumstance.
Comments
Post a Comment