Skip to content

Instantly share code, notes, and snippets.

@chrisdpeters
Created February 23, 2012 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdpeters/1895543 to your computer and use it in GitHub Desktop.
Save chrisdpeters/1895543 to your computer and use it in GitHub Desktop.
Wheels + jQuery Partial for Setting Form Focus
<cfparam name="arguments.focus" type="string" default="">
<cfif Len(arguments.focus)>
<cfoutput>
<script type="text/javascript">
$(document).ready(function(){
$("#arguments.focus#").focus();
});
</script>
</cfoutput>
</cfif>
$(document).ready(function(){
$("#my-form-element").focus();
});
<!--- Note: This should be <cfparam>'ed earlier in the file, of course --->
#includePartial(name="/layout_focus", focus=layout.focus)#
<cfset layout.focus = "##my-form-element">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment