‘jQuery’ Archive

jQuery UI: Datepicker for birth date input July 11, 2009 No Comments

I decided to use jQuery UI Datepicker control for one of project and faced with the some strange behavior. At first, I decided to find a way to select month and year quickly because switching months with previous button will unhappy every user. So I’ve added the following options:

$(‘#datepicker’).datepicker({
    changeMonth: true,
    changeYear: true
});

Well [...]

Open link in a new window in XHTML 1.0 Strict June 24, 2009 No Comments

As you may notice using target=”_blank” breaks XHTML 1.0 Stric validation. And here you are a solution with jQuery:

Add rel=”external” for links that you want to be opened in a new window
Include the following jQuery script:

$(function() {
  $("a[rel*='external']").click(function() {
    window.open($(this).attr(‘href’), ‘external’, ”);
  });
});

But I agree that it’s annoying when link is opening in new [...]

jQuery tips and tricks: ‘Add more’ functionality in a table June 23, 2009 No Comments

Usually we have ‘Add more’ link on the forms. For example, on the project I’m working on right now there is registration form and user with Advanced package can create a few accounts. So we have ‘Add more’ link that should add one more row with Name, Email and Password for adding another account. Because [...]

Focus element in ThickBox March 24, 2009 No Comments

I faced with a problem focusing element in thickbox popup. I open login form using thickbox and want to take a focus on the first element of the form. Though the following code does look to be working:

$(document).ready(function() {
    $("input[name='username']").focus();
});

But there is a little trick. If you make a small 100ms delay in focus() [...]