Alex Rivera | Logout

Post your short extension functions goodies for jQuery

Asked 2009-01-11T14:58:09.010
12

In a similar vain to the c# extension topic on SO It would be great if we could pull together a whole host of useful jQuery function extensions.

Please Note the idea is to have short snippets of code not full blown well known plugins or ui widgets

Edit
Report

1 Answer

1

Quick and easy AJAX:

The following allow you to make anchors like

<a href='http://www.google.com/' rel='#myselector' class='ajax' />

which do an AJAX query on the href URL and inject the result into the first element defined by the selector in the anchor's rel attribute.

// Allow hrefs with the class 'ajax' and a rel attribute set with a selector to load content via ajax into the selected element.
$('.ajax').unbind('click').click
(
    function(e)
    {
        $($(this).attr('rel')).load($(this).attr("href"));
        e.preventDefault();
    }
);
answered 2009-09-01T08:31:21.120

Your Answer