Don't forget to add the onload.js as the last javascript file in your
layout!
On Apr 30, 2007, at 2:54 PM, Jordan A. Fowler wrote:
Glenn,
Something I like to do, to keep things clean is to setup a
Javascript onLoad Queue, which is an array of functions that should
be run upon the page being loaded.
In your application.js file, add:
var onLoadQueue = [];
Then, you can add application wide onload items to the queue or add
controller/action specific javascript files, within which you just
add to the queue as follows:
onLoadQueue.push(function () {
$('text_field_id').focus();
alert("i've been called!");
});
Add another file called onload.js to your javascripts directory and
add this code to it:
onLoadQueue.each(function (f) {f();});
Let me know if you have any questions.
-Jordan
On Apr 30, 2007, at 2:48 PM, Glenn Little wrote:
I'm trying to set the initial focus to some specific form
field on a page.
I can use a prototype call to do something like:
<% form_tag .... %>
<%= text_field_tag ... %>
<script>$('text_field_id').focus();</script>
<%= some_other_field_tag... %>
and it works, but I'm just wondering if there was a cleaner
way that I'm missing. Ideally, I'd like not to have to
explicitly state the id of the input element. Have I missed out
on an :initialfocus => true option to the form field helpers
or anything like that?
Thanks...
-glenn
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby
--------------------------------------------------------------
Jordan A. Fowler
1830 Market St. #4
San Diego, CA 92102
E-mail: [EMAIL PROTECTED]
AIM: virtuosojordan
Phone: 406.546.8055
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby
--------------------------------------------------------------
Jordan A. Fowler
1830 Market St. #4
San Diego, CA 92102
E-mail: [EMAIL PROTECTED]
AIM: virtuosojordan
Phone: 406.546.8055
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby