Music. Coding. Gaming. Life.

jQuery-Default-Button 1.2

Posted Sunday, December 18th, 2011 7:29:00 am
I have committed version 1.2 of my jQuery Default Button plugin to Github just now. This update addresses two issues.

First, I wasn't returning the object, meaning you couldn't do jQuery style chaining with it. Now you can.

The second issue was more obscure, and I probably spent about 2 hours trying to figure this out on a project I've been working on. I am also using the jQuery Tiny Watermark plugin which displays a watermark in an input field when it doesn't have focus. The problem I was running into was that fields that used this watermark would stop responding to the enter key after a while.

It took me a while to figure out the problem. The watermark works by replacing the input boxes every time focus is gained or lost, and every time you replace the input box, it loses its events.

The solution was to let the event bubble up to the containing DIV, check to see if the element causing the event was an INPUT element, and then firing the click event on the target element. Not only does this resolve my problem, but it has the added benefit of using less memory because there's one event handler per form, not one event handler per INPUT on the form.


Loading... Media Player