Last active
December 14, 2015 06:39
-
-
Save nickjacob/5044374 to your computer and use it in GitHub Desktop.
just an idea I wanted to play with; for a searching app, shouldn't the user be able to refresh and get the same parameters in the field/query?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputRe = /input|select|textarea/i # some browsers do uppercase tagNames; also faster than 3 strcmp | |
cache = {} | |
elByName = (el) -> | |
cache[el.name] ?= document.getElementsByName el.name | |
document.addEventListener 'load', (e) -> | |
document.addEventListener 'change', (e) -> | |
target = e.target | |
if inputRe.test target.tagName | |
window.location.search ||= '?' | |
window.location.search += "#{ target.name }=#{ [ t.value for t in elByName target.name ].join ',' ]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment