jQuery extension to ajax-ify selected links to stay inside a container

Make your links stay in a container, great for will_paginate / sorting headers and friends 🙂

// ajaxify all links that have “tab=my_container” in their href


  // make selected links in a container replace the container
  // https://grosser.it/2012/06/21/jquery-pjaxcontainer-extensions
  $.fn.ajaxifyContainer = function(selector){
    selector = selector || 'a';
    var $container = $(this);
    $(selector, $container).live('click', function(){
      $container.html("Loading ...").load($(this).attr("href"));
      return false;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s