January 17th, 2008
Setting focus on the first text field with jQuery is as simple as
$("input:text:first").focus();
$("input:text:first:visible").focus();
Update: “visible” filter added to selector, thanks to verrier.
Update: If you are on Rails use auto_focusable_forms, dependency free plugin that will focus first input for you.
Find more at http://docs.jquery.com/Selectors
Tags: focus, form, jQuery, selectors
Posted in jQuery | 3 Comments »
December 8th, 2007
While surfing the Web, you probably noticed the dotted outline, that appears when you click on the link. If your link doesn’t lead to another page, but instead triggers some event in the same page, outline stays there and looks ugly.
For modern browsers you can remove it with simple css:
a:focus, a:active {
outline:none;
}
Unfortunately, this won’t do for IE 6 and earlier.
With jQuery it’s easy to get rid of the outline in every browser that has JavaScript enabled:
$("a").click(function() {
$(this).blur();
});
This will remove outline from the link once he is clicked. You will see the outline when clicking, but it will not stay there.
If you don’t want to se the outline at all replace click event with focus event:
$("a").focus(function() {
$(this).blur();
});
To find more about jQuery Events visit http://docs.jquery.com/Events
Posted in jQuery | 3 Comments »
November 23rd, 2007
The simplest way to disable sessions in Rails is to use session :off (see ActionController::SessionManagement::ClassMethods).
session :off
To disable session suport only for a specific controller add session :off to that controller
class MyController < ApplicationController
session :off
end
Written like that, sessions are disabled for all actions on this controller.
Like filters, you can specify :only and :except clauses to restrict subset. The following code will disable session for first_action and third_action, but not for second_action.
class MyController < ApplicationController
session :off, :only %w(first_action third_action)
def first_action
end
def second_action
end
def third_action
end
end
Read the rest of this entry »
Posted in Rails | 1 Comment »