Report abuse


			
class AssetsController < ApplicationController

layout proc{ |c| c.request.xhr? ? false : "assets" }  

# ^ loose layout if page is requested using Ajax. 
# This method is better than using respond_to imho.

  def show
    @asset = Asset.find(params[:id])
  end

end

view: assets/show.rhtml

# Put everything you don't want to be shown if the page is grabbed with ajax 
# in the layout

  <%= h(@asset.description) %>


# your main view, wherever and whatever it happens to be:

    


# Ajax function (mootools library, refer to Prototype docs for the minor modifications 
# necessary to get it running with default Rails js):

window.addEvent('domready', function(){

        var assets = $$('#myassets li');

        assets.each(function(element){
          var target = this.$$('.update')
          var link = this.$$('a')

        link.each(function(el){
          el.addEvent('click', function(e) {
                        new Event(e).stop();
                        var url = el.getProperty('href')
                        new Ajax(url, {
                                method: 'get',
                                update: target,
                                onRequest: function(){ 
                                  },
                                onComplete: function() {
                                  }
                                  }).request();
                          })
             })
          })
})