CFWheels is only a hammer

October 8, 2009 · Chris Peters

I must admit that I was using CFWheels as a hammer and trying to treat a problem like a nail when I wrote about creating a CFWheels partial for setting form focus.

My posting this is a seriously delayed reaction. But I must admit that I was using CFWheels as a hammer and trying to treat a problem like a nail when I wrote about creating a CFWheels partial for setting form focus.

Stephen came up with a much nicer jQuery-only solution for setting form focus:

$(document).ready(function(){
$(.focus”).focus();
});
view raw gistfile1.js hosted with ❤ by GitHub

So now you can set form focus on load by setting that element’s class to focus. No need to create a CFWheels partial and set a variable in your CFML.

In my newbness, I wasn’t thinking that you could have that $(".focus") hanging there without it applying to something on every page. Now I am schooled.

Thanks Stephen!

About Chris Peters

With over 20 years of experience, I help plan, execute, and optimize digital experiences.

Leave a comment