Day Barr's personal website.

Find index of selected option

jQuery code snippet to find the index of the option that has been selected from within a select element.

$('select').change(function() {
  $('#output').text( $(this).children().index( $(this).children(':selected') ) );
}).trigger('change');

Use jQuery's index function to return the index of the item that matches the ':selected' selector within the children of the select element.

Example:

Pipe to filter the Google Code Issue Updates feed

Google Code provides various feeds for every project they host. The "Issue Updates" feed contains entries for all the issues on the project. What if you're only interested in one issue? Filter the feed with Yahoo! Pipes of course.

My pipe is an example of how easily this can be achieved with a simple regex in the Filter module. I've tied the name of the project and the issue number to user inputs, so you can use this pipe to track your favourite issue on your pet project. Personally, I'm looking forward to having support for Pie Charts baked into an official release of flot, and will be tracking progress with this feed.

Browser support for built-in Ajax Libraries

When Google launched the Ajax Libraries API in May, Dion Almaer noted that it might be possible for browsers to further improve performance of applications using this API:

If we see good usage, we can work with browser vendors to automatically ship these libraries. Then, if they see the URLs that we use, they could auto load the libraries, even special JIT'd ones, from their local system. Thus, no network hit at all!

A great idea, but as far as I know not one that any browser has currently taken up. When Google announced Chrome in September I wondered if they might be the first browser to support such a feature. Today I finally got around to testing the latest Chrome using Wireshark and discovered that it doesn't yet do this, at least not for the latest jQuery release.

So I've taken affirmative action in the spirit of John Resig's recent advice and filed a feature request at the Google Chrome support site.

Array.splice: deleteCount not optional

JavaScript: The Definitive Guide

I recently ran across some curious JavaScript behaviour. Nothing new there, but I was slightly annoyed to see that my handy reference book hadn't given me any clue about the inconsistent way in which different browsers handle the Array.splice method. O'Reilly's JavaScript: The Definitve Guide (5th edition) is usually pretty good at pointing out any browser compatibility issues.

But after digging some more, I was even more confused to find that the book seemed to be wrong in its description of the method.  ...read more »

Yahoo! Pipes, Caching and robots.txt

Every time I create or use a pipe, I'm indirectly causing hits on some third party's website.  So I was curious to learn how the Yahoo! Pipes backend behaves.  What caching does it do, is it a good and well behaved web citizen in general?

There isn't much official documentation to go on.  The Pipes Troubleshooting guide has some notes on how to stop Pipes from downloading a feed too frequently and how to stop Pipes from using feeds at all.

So, I put myself in the shoes of the third party website that the pipes hit upon to find out more.  ...read more »

Syndicate content Syndicate content