Forum: Ruby on Rails in_place_editor with local autocomplete

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
70375a32ad79987b9bc00cb20f7d1c95?d=identicon&s=25 Dean (Guest)
on 2006-05-16 09:56
(Received via mailing list)
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

Sounds like I'm going to have to create two divs, one with value and one
with input, and switch their visibility.  Other suggestions?

This topic is locked and can not be replied to.