jQuery Plugins
Written by steve on 04-27-2008 at 05:48 PM
Today I posted a couple of simple jQuery plugins on github. They are:
jquery.focus_first.js
jquery.rails_ajax_hook.js
You can clone them by doing:
<pre>
git clone git://github.com/sxross/jquery_plugins.git
</pre>
The first one simply sets the focus on the first INPUT element in a form, if such a form exists. Usage:
<pre>
$(document).ready(function(){
$(this).focusFirstInput();
}
</pre>
That’s it!
The second, ajaxLinkBind, is more complicated. Its purpose is to bind to an ‘a’ element and invoke some Ajax action in a Rails controller. Here’s how it works.
(X)HTML
<pre>
<div class='linkable-by-ajax'>
hey <a href="/some/place">click here</a>.
<span id="update-me"></span>

