I just whipped this up and figure I'd crowd-source the debugging. :) It's a name-one that stores the completions locally rather than going off to the server. It slots nicely between select- one and name-one. It works for me, but I haven't tried to break it yet. Suggestions for a better name are also welcome.
the DRYML: <def tag="name-one-local" attrs="options, min-chars, nil-value"> <% options ||= begin conditions = ActiveRecord::Associations::BelongsToAssociation.new(this_parent, this_field_reflection).conditions this_field_reflection.klass.all(:conditions => conditions, :limit => limit).select {|x| can_view?(x)} end min_chars ||= 0 value = name(:no_wrapper => true, :if_present => true) -%> <div class="name-one-local"> <ul class="name-one-local-data" style="display:none;"> <repeat with="&options"> <li><%= this.to_s %></li> </repeat> </ul> <input type="text" name="#{param_name_for_this}" class="local-autocompleter #{type_and_field._?.dasherize} #{css_data :min_chars, min_chars} #{'nil-value' if value==''}" value="#{value=='' ? nil_value : value}" merge-attrs/> <div class="completions-popup" style="display:none;"></div> </div> </def> the javascript: LocalAutocompleteBehavior = Behavior.create({ initialize : function() { this.minChars = parseInt(Hobo.getClassData(this.element, "min- chars")); var data = this.element.previous(".name-one-local- data").childElements().map(function(el) {return el.innerHTML;}); this.autocompleter = new Autocompleter.Local(this.element, this.element.next('.completions-popup'), data, {minChars: this.minChars, afterUpdateElement: this.afterUpdateElement}); }, onfocus: function() { if(this.element.hasClassName("nil-value")) { this.element.value = ''; this.element.removeClassName("nil-value"); } if(this.minChars==0) { this.autocompleter.activate(); } }, afterUpdateElement: function(input, li) { input.fire("rapid:autocomplete-assigned"); } }); Event.addBehavior({ '.local-autocompleter' : LocalAutocompleteBehavior() }); -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to hobous...@googlegroups.com. To unsubscribe from this group, send email to hobousers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.