Hi Rails gals n guys
I am trying to enhance the "Lightning-Fast JavaScript Autocompletion"
rails recipe. For those that do not have the pdf-book the recipe
explains how to use a javascript array for an auto-complete text field.
I want to combine this with the in_place_editor call. My current
(unworking) code:
<!-- Load the array for autocomplete -->
<script src="<%= url_for( :controller => "styles",
:action => "jsarray"
) -%>" type="text/javascript"></script>
<!-- div to make into a in-place editor -->
<div id="style_lookup">Change Style</div>
<!-- autocomplete div -->
<div class="auto_complete"
id="style_auto_complete"></div>
<%= in_place_editor( "style_lookup", { :url => url_for(
:controller =>
"styles", :action => "style_jdetails" ), :script =>
true } ) %>
<%= javascript_tag("new Autocompleter.Local(
''style_lookup'' ,
''style_auto_complete'', styleArray, { fullSearch: true,
frequency: 0,
minChars: 1 });") %>
The problem here is that in_place_editor creates an input tag with no
id, so the Autocompleter can not find it.
Even if I could get the in_place_editor to id the input, would the
Autocompleter work since the input tag does not exist when the document
loads?
Sounds like I''m going to have to create two divs, one with value and
one
with input, and switch their visibility. Other suggestions?
Thanks,
--Dean