Class: Nitro::AsyncMorpher

Inherits:
SharedMorpher show all
Defined in:
lib/nitro/helper/javascript/morphing.rb

Overview

Transform a normal achor into an asynchronous request:

<a href="..." async="true">...</a>

becomes

<a href="#" onclick="new Ajax.Request...; return false;">...</a>

Instance Method Summary collapse

Methods inherited from SharedMorpher

#record_css, #record_js, #require_script_file

Methods inherited from Morpher

#after_end, #after_start, #before_end, #initialize

Constructor Details

This class inherits a constructor from Nitro::Morpher

Instance Method Details

#before_start(buffer) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/nitro/helper/javascript/morphing.rb', line 48

def before_start(buffer)
  require_script_file :prototype
  
  href = @attributes['href'] 
  @attributes['href'] = '#'
  @attributes['onclick'] = "new Ajax.Request('#{href}'); return false;"
  @attributes.delete(@key)
end