dominictarr/observable — pull request #1 by 1N50MN14 (2013-02-22 03:31:22+00:00)
Title: support for select

Added new method .select(element). Doesn't take attr or event as this can be achieved using .attribute(). Listener set to "change". Modified listen() so that onEvent() looks like this now:

function onEvent () {
attr === -1 ? listener(element[element.selectedIndex].value)
: listener(element[attr])
}

Didn't think it's wise to create a special listen() for .select() as listen() is called only once so there should be no edge case here (?). I'm using -1 instead of null or undefined as I'm planning to make a similar implementation for radio boxes, will give it -2.

This should cover it all, with the exception of multi-select; which I guess would be an observable array.