Last active
December 15, 2015 23:29
-
-
Save samedhi/5340681 to your computer and use it in GitHub Desktop.
I am trying to grab a id="search-box" element and give it focus. I do get "I was able to grab it!" with the code below. Unfortunately, the search-box element in question does not get focus. To be clear, the search-box is on the initial (on-load) page. The search-box element is in template code. Is on-load too early for elements that are rendered…
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
window.onLoad.listen((Event e){ | |
Element elem = query("#search-box"); | |
if(elem != null){ | |
print("I was able to grab it!"); | |
elem.focus(); | |
}else{ | |
print("I was not able to grab the element"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment