Tuesday, July 20, 2010

Select ALL - jQuery

I am so happy that i can achieve things in 1 line of code using jQuery.
To Select all the checkboxes in the grid..
$(":checkbox").each(function() { this.checked = document.getElementById('chkAll').checked; });

To findout atleast one checbox should be selected
var isChecked = false;
$(":checkbox").each(function() { if (this.checked == true) isChecked = true; });

or
if ($(":checkbox:checked").length > 0) {
isChecked = true;

}

Friday, July 16, 2010

jQuery Part3

jQuery has lot of cool features. We can achieve things in less code and we have a library/framework(jQuery) behind us :)

ok...lets see what i have learned today

$(document).scrollTop()
$('#TextArea1').resizable() - This can be used for scrolling and split panes
Lightbox & colorbox - to show image popups

Wednesday, July 14, 2010

JQuery Continued...

This post is continuation of the yesterdays jQuery article. I am listing down the jQuery methods that i learned today.
toggle - instead of using show() and hide() methods we can use toggle() method.
$('#Button2').toggle('slow');
instead of
if ($("#Button2").is(':visible')) {$("#Button2").hide();}
else {$("#Button2").show();}

css class, mouseover, mouseout - addClass & removeClass can be used to add/remove CSS class to the elements as below.
$('#GridView1 tr').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); })
Plugins - Lot of animation functionality is not included in the jQuery master file due to the size factor. Lot of plugins(http://plugins.jquery.com)available to download.
one of the good plugin for animation is Easing (http://plugins.jquery.com/project/Easing )
Chaining Actions - More than one action can be done by calling jQuery methods one on another.
$('p:last').effect('shake', { times: 5 }, 300).effect('highlight', {}, 3000).hide('explode', {}, 500);


Tuesday, July 13, 2010

Today's snippets

HTC 1 - design fabulous
I have come across this site while reading google news.
Excellent designs by Andrew Kim. Have a look, it is worthy.
http://designfabulous.blogspot.com/

kudos and hats off to you

Xperia X10 software update - OTA
Sony ericsson finally rolled out Over the Air update to speed up Xperia X10.
http://blogs.sonyericsson.com/products/2010/06/30/xperia-x10-software-update%E2%80%A6-over-the-air/

JQuery

I am going through the jQuery: Novice to Ninja book. Find the useful snippets about jQuery below.

jQuery UI - jQuery User Interface, and it comprises a menagerie of useful effects and advanced widgets that are accessible and highly customizable through the use of themes.

It’s Just JavaScript! - Never forget that jQuery is just JavaScript! It may look and act superficially differ-ent—but underneath it’s written in JavaScript

$(document).ready() - Almost everything you do in jQuery will need to be done after the document is ready. It can be represented as just $(function() { alert('Hello World!'); } );

Firebug - Firebug is a particularly useful tool for examining the DOM in your browser

Accessing Grid - Grid rows can be accessed by the below jQuery $("#GridId tr"), firest row can be accessed as $("#GridId tr:first") and nth row can be accessed as $("#GridId tr:eq(n)")

CSS, Styles - Following jQuery can be used to set the grey background color in the odd rows. $("#GridId tr:odd") .css('background-color', 'gray')

This is for today.... Have a nice Programming Day :)