Friday, January 22, 2010

jQuery 1.4 Give Us a New Way to Zebra Stripe

In jQuery 1.4 all setter methods have been extended to take in a setter function.  Before only .attr() had the ability to use a function to return the value to set. Now you can pass a setter function to .css(), .attr(), .val(), .html(), .text(), .append(), .prepend(), .before(), .after(), .replaceWith(), .wrap(), .wrapInner(), .offset(), .addClass(), .removeClass(), and .toggleClass().

The setter function can take two arguments, the index position of the element in the set and the old value of the element.

.css( propertyName, function(index, value))

With setter functions now available we can use this in a new way to zebra stripe a set of elements.  In this example we'll stripe a unordered list:

HTML:

<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
<li>item 6</li>
<li>item 7</li>
</ul>
jQuery 1.4:

$(document).ready(function(){
$("li").css("background-color", function(i){
return (i % 2 === 0) ? "#cccccc": "#FFFFFF";
});
});

We select all the LIs and call the .css() setter method. We give it the property name we want to update, background-image and we pass a function that will return the value we want to set.

The function tests if the index that we passed in i is MOD 2 (simply is it even or odd), if even set the color to #cccccc else set it to #FFFFFF.

Demo: (jsbin)

Note: Obviously, this isn't the best way to do zebra stripping with jQuery but I like to explore different ways to do the same thing to learn the techniques.

Monday, January 18, 2010

14 Days of jQuery - Behind the Scenes - yayQuery

14 Days of jQuery - Behind the Scenes - yayQuery from Ralph Whitbeck on Vimeo.

yayQueries Paul Irish steals my flip and records some video while we were out eating after day two of video recording.

Saturday, January 16, 2010

14 Days of jQuery - Behind the Scenes - Part 7

14 Days of jQuery - Behind the Scenes - Part 7 from Ralph Whitbeck on Vimeo.

The team feverishly works to get the Day 2 blog out before the stroke of midnight, everyone that is except...

Friday, January 15, 2010

14 Days of jQuery - Behind the Scenes - Part 6

14 Days of jQuery - Behind the Scenes - Part 6 from Ralph Whitbeck on Vimeo.

Ralph and Elijah are recording 6 podcasts while everyone is together. Here we are talking with Mike Hostetler and Jonathan Sharp about appendTo for a future episode.

14 Days of jQuery - Behind the Scenes - Part 5

14 Days of jQuery - Behind the Scenes - Part 5 from Ralph Whitbeck on Vimeo.

John Resig, Jonathan Sharp and Richard Worth are doing final sound checks. Here's a look at the set up.

Thursday, January 14, 2010

14 Days of jQuery - Behind the Scenes - Keynote

14 Days of jQuery - Behind the Scenes - Keynote from Ralph Whitbeck on Vimeo.

This is a look at the production team behind the keynote.

14 Days of jQuery - Behind the Scenes - Part 4

14 Days of jQuery - Behind the Scenes - Part 4 from Ralph Whitbeck on Vimeo.

Richard D. Worth and Jonathan Sharp are setting up the room for our live uStream with John Resig and other members of the jQuery team

14 Days of jQuery - Behind the Scenes - Part 3

14 Days of jQuery - Behind the Scenes - Part 3 from Ralph Whitbeck on Vimeo.

The team is finallizing the 1.4 release blog post. Heads are down and working feverishly to get it out.

14 Days of jQuery - Behind the Scenes - Eric Passmore

14 Days of jQuery - Behind the scenes - Eric Passmore from Ralph Whitbeck on Vimeo.

We sat down with Eric Passmore, Aol's Senior Vice President, Global Publishing Systems and talked about Aol. use of jQuery and thank him for the use of the facility.

14 Days of jQuery - Behind the Scenes - Part 2

14 Days of jQuery - Behind the Scenes - Part 2 from Ralph Whitbeck on Vimeo.

The team is finally together and waiting to head out to dinner.

Wednesday, January 13, 2010

14 Days of jQuery - Behind the Scenes - Part 1

14 Days of jQuery - Behind the Scenes - Part 1 from Ralph Whitbeck on Vimeo.

The team that came early is testing the video equipment at Richard D. Worth's house.

Heading to DC for the 14 Days of jQuery

I am currently sitting in the JetBlue terminal in JFK. I am on my way to Washington DC where I will meet most of the rest of the jQuery team and my jQuery Podcast cohost Elijah Manor.

We are going to be working on filming the talks and releases for the 14 Days of jQuery which starts tomorrow.

Elijah and I will be podcasting like mad men. Tomorrow we plan to interview John Resig about the jQuery 1.4 release and we do plan to release that episode on Friday. In addition to that episode we are planning to record four other episodes with other team members which we will release in the coming weeks. So much to look forward too.

Additionally to all the podcasting and video production for the 14 Days of jQuery, I'll be taking video's of "behind the scenes" and uploading them to ralphwhitbeck.com, so check back often or follow @jQueryPodcast Twitter account to see when new videos are posted.

The team is pretty excited to be able to bring the 14 Days of jQuery (not to mention a little tired) but I hope the community gets tons of value from all this work.

Saturday, January 02, 2010

Getting "Up-to-speed"

I was looking over my blog this week while I was out on holiday vacation and noticed I haven't posted a blog post since October.  So much has happened since then I think perhaps a "getting the reader up-to-speed" post is in order.  

So here we go...

jQuery Team member

Early last year, I made it a goal to blog, tweet and personally evangelize jQuery to better myself and the project.  My efforts got noticed by jQuery Evangelist Rey Bango and he brought me in as a advisor to the jQuery team.  While I was an advisor I took advantage of my situation and jumped in on projects the team was working on.  Mainly, the jQuery Conference in September and the Stack Overflow Dev Days talk in Toronto.

In November, it was voted on by the jQuery team to bring me on as a jQuery Team Member and I was added to the evangelism team.  I was truly surprised and honored by this action as I wasn't expecting it at the time. 

Being a team member made it easier for me to launch my new project...

The Official jQuery Podcast

I announced in October, at Stack Overflow Dev Days in Toronto, that I would be starting the Official jQuery Podcast in November.  I worked with the jQuery team to get infrastructure support and found a cohost, in Elijah Manor, that could give an outsiders perspective on topics.

We initially started with streaming the shows live on uStream.  But I think I am finding that to be too stressful and am reevaluating whether that is still viable.  Maybe at a later date.

Our first show, with guest John Resig, got the show ranked to #2 on the top Technology podcasts for the day which was very exciting.

We've since had guests Richard D. Worth, Paul Irish, Cody Lindley and Rey Bango.

Our planned shows for January will sure to be very exciting. We are planning to travel to Washington DC to do some shows live in person with the people we are going to interview.

You can find our show on iTunes or you can subscribe to the show with the raw RSS feed.

My plans for now are to do a weekly show as long as I can sustain them throughout 2010.

Coming up in 2010

I don't have many plans for 2010 at this point but there are a few things I am planning on.

We are currently in the middle of planning something huge for jQuery this month.  I'll be travelling with Elijah to cover the "something huge" for the Official jQuery Podcast.

In addition, there will be physical conferences in San Francisco, London and Boston.  I am hoping to at least attend the conferences that won't require a passport.
I am currently scheduled to give a talk on jQuery at LUGOR (Linux User Group of Rochester) on May 20th at RIT.

So there you go you should now be sufficiently "up-to-speed."

The Official jQuery Podcast

with Ralph Whitbeck & Rey Bango

You can subscribe to the show in iTunes or via the raw RSS feed

My Twitter Updates

View Twitter Page