Set focus on first field with jQuery
January 17th, 2008Setting focus on the first text field with jQuery is as simple as
$("input:text:first").focus();
Find more at http://docs.jquery.com/Selectors
Setting focus on the first text field with jQuery is as simple as
$("input:text:first").focus();
Find more at http://docs.jquery.com/Selectors
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
The simplest way to disable sessions in Rails is to use session :off (see ActionController::SessionManagement::ClassMethods).
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