Mux Demux plugin

Plugin details

A ruby on rails plugin that allows you to very easily update multiple sections of a page using a SINGLE Ajax call. Just map rails URLs to HTML element ids or even register a Javascript-Callback to handle the response of every URL.

Websitehttp://rubyforge.org/projects/mux-demux/ Repositorysvn://rubyforge.org//var/svn/mux-demux Author Karthik C Tags AJAX LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install svn://rubyforge.org//var/svn/mux-demux

Copy the 'javascript/mux-demux.js' file to your projecrs 'public/javascripts' folder. Make sure to include both 'json.js' and 'mux_demux.js' in your views

OK... THE CODE CAN TALK NOW
==========================

    new Ajax.MuxDemux([
      {container: 'tag_cloud',       url:'/tags/show_cloud'},
      {container: 'book_details',   url:'/book/details/10?level=3'},
      {container: 'book_header',  url:'/book/header'}
    ])


Yes, that's all the code you need to write to update the elements 'book_details', 'tag_cloud' and 'page_footer' using their corresponding urls... all in just a SINGLE ajax call.

Also, the server-side rails actions can be implemented in the usual manner. For Eg:

class TagsController < ApplicationController
  def show_cloud
    @tags = Tags.find_all
    render :partial => 'cloud'
  end
end


Alternatively, instead of updating an element you can register a callback to handle the response from the url, as shown below:

    new Ajax.MuxDemux([
      {container: 'tag_cloud', url:'/tags/show_cloud'},
      {url: '/book/details/10',
        processResult: function(response) { update_book_details(response,3) }
      }])


....and you can also pass in the usual set of options accepted by prototype's Ajax.Request class, like:

    new Ajax.MuxDemux([
      {container: 'tag_cloud',       url:'/tags/show_cloud'},
      {container: 'book_details',   url:'/book/details/10?level=3'}
      ],
      {asynchronous: true, onLoading: start_spin_wheel, onLoaded: stop_spin_wheel}
    )

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 7 months ago