# Auto Complete using tex input

**URL:** <https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445>\
**Category:** Ruby\
**Created:** [December 7, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445 "2007-12-07T17:41:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 7, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/1 "2007-12-07T17:41:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 7, 2007, 9:23pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/2 "2007-12-07T21:23:06Z")

</div>

On Dec 7, 2007, at 5:41 PM, Neha C. wrote:

> 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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 7, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/3 "2007-12-07T21:25:09Z")

</div>

But i cant use the tag directly.  
I want to use it this way

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

Xavier N. wrote:

> On Dec 7, 2007, at 5:41 PM, Neha C. wrote:
> 
> > 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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 7, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/4 "2007-12-07T23:10:30Z")

</div>

On Dec 7, 2007, at 9:25 PM, Neha C. wrote:

> But i cant use the tag directly.  
> I want to use it this way
> 
> 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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 10, 2007, 6:29pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/5 "2007-12-10T18:29:14Z")

</div>

Hi,

What will completion\_options[:skip\_style] be?

I have implemented it like  
  
\<%=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 N. wrote:

> On Dec 7, 2007, at 9:25 PM, Neha C. wrote:
> 
> > But i cant use the tag directly.  
> > I want to use it this way
> > 
> > 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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [December 12, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/auto-complete-using-tex-input/122445/6 "2007-12-12T21:25:35Z")

</div>

On Dec 10, 2007, at 6:29 PM, Neha C. wrote:

> 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  
>   
> \<%=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](http://agilewebdevelopment.com/plugins/model_auto_completer)  
that receives a hash of options called completion\_options.
