Class: Nitro::AutoCompleteMorpher
- Inherits:
-
SharedMorpher
- Object
- Morpher
- SharedMorpher
- Nitro::AutoCompleteMorpher
- Defined in:
- lib/nitro/helper/javascript/morphing.rb
Overview
Adds auto-complete functionality to a standard input field.
Example
<input type=“text” id=“myfield” name=“myfield” auto_complete=“true” />
You need to provide the autocomplete values by means of a custom action: field_id_auto_complete. The method should return a <ul> list. In this example:
def myfield_auto_complete
%{<ul><li>....</ul>}
Instance Method Summary collapse
Methods inherited from SharedMorpher
#record_css, #record_js, #require_script_file
Methods inherited from Morpher
#after_start, #before_end, #initialize
Constructor Details
This class inherits a constructor from Nitro::Morpher
Instance Method Details
#after_end(buffer) ⇒ Object
155 156 157 |
# File 'lib/nitro/helper/javascript/morphing.rb', line 155 def after_end(buffer) buffer << %|<div id="#{@id}_auto_complete" class="auto_complete"> </div>| end |
#before_start(buffer) ⇒ Object
144 145 146 147 148 149 150 151 152 153 |
# File 'lib/nitro/helper/javascript/morphing.rb', line 144 def before_start(buffer) require_script_file :prototype, :effects, :controls id = @id = @attributes['id'] || @attributes['name'] update = @attributes['auto_complete_update'] || "#{id}_auto_complete" url = @attributes['auto_complete_url'] || "#{id}_auto_complete" js "new Ajax.Autocompleter('#{id}', '#{update}', '#{url}');" @attributes.delete(@key) end |