Auto Complete using tex input

N

Neha Chopra

I have to use the auto complete but i cant use the
text_field_with_auto_complete. i have to use it with a standard input
text box. Can someone help me with what javascript to embed to enable it
to work.
 
X

Xavier Noria

I have to use the auto complete but i cant use the
text_field_with_auto_complete. i have to use it with a standard input
text box. Can someone help me with what javascript to embed to
enable it
to work.

You are done, text_field_with_auto_complete uses a standard text
field :).

-- fxn
 
N

Neha Chopra

But i cant use the tag directly.
I want to use it this way
<input type="text" id="criteria[<%=count%>][data_autocomplete]"
name="criteria[<%=count%>][data_autocomplete]" size="60"
autocomplete="on"/>

and i dont know what javascript to pass so that observer gets fired and
all.
Please help.
 
X

Xavier Noria

But i cant use the tag directly.
I want to use it this way
<input type="text" id="criteria[<%=count%>][data_autocomplete]"
name="criteria[<%=count%>][data_autocomplete]" size="60"
autocomplete="on"/>

and i dont know what javascript to pass so that observer gets fired
and
all.

This is a starting point, where each component is more or less self-
explanatory:

return <<-HTML
#{auto_complete_stylesheet unless
completion_options[:skip_style]}
#{text_field_tag tf_name, tf_value, tag_options}
#{content_tag("div", "", :id =>
"#{tf_id}_auto_complete", :class => "auto_complete")}
#{auto_complete_field tf_id, completion_options}
HTML

You create custom HTML elements, and after that delegate in
auto_complete_field.

-- fxn
 
N

Neha Chopra

Hi,

What will completion_options[:skip_style] be?

I have implemented it like
<input type="text" id="criteria[<%=count%>][data_autocomplete]"
name="criteria[<%=count%>][data_autocomplete]" size="60"
autocomplete="off"/>
<%=content_tag("div", "", :id =>"#{@data_elem.id}_auto_complete", :class
=> "auto_complete") %>
<%=auto_complete_field @data_elem.id%>

and i am getting missing variable name an error in prototype.js.


Xavier said:
But i cant use the tag directly.
I want to use it this way
<input type="text" id="criteria[<%=count%>][data_autocomplete]"
name="criteria[<%=count%>][data_autocomplete]" size="60"
autocomplete="on"/>

and i dont know what javascript to pass so that observer gets fired
and
all.

This is a starting point, where each component is more or less self-
explanatory:

return <<-HTML
#{auto_complete_stylesheet unless
completion_options[:skip_style]}
#{text_field_tag tf_name, tf_value, tag_options}
#{content_tag("div", "", :id =>
"#{tf_id}_auto_complete", :class => "auto_complete")}
#{auto_complete_field tf_id, completion_options}
HTML

You create custom HTML elements, and after that delegate in
auto_complete_field.

-- fxn
 
X

Xavier Noria

What will completion_options[:skip_style] be?

Please ignore that line, it says: inline the CSS for auto completion
unless specified otherwise[*]. You probably want an external CSS for
this stuff anyway.
I have implemented it like
<input type="text" id="criteria[<%=count%>][data_autocomplete]"
name="criteria[<%=count%>][data_autocomplete]" size="60"
autocomplete="off"/>
<%=content_tag("div", "", :id
=>"#{@data_elem.id}_auto_complete", :class

Instead of @data_elem.id you need to use the ID of the text field.
=> "auto_complete") %>
<%=auto_complete_field @data_elem.id%>

Same here.

-- fxn

[*] That code was copied from a helper of http://agilewebdevelopment.com/plugins/model_auto_completer
that receives a hash of options called completion_options.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top