Correct use of :complete and :before on a text_field_with_auto_complete?

Hey guys!

Having a problem here figuring out how to use my :before and :complete statements in a text_field_with_auto_complete construct.

At the moment, I have this bit of code within an edit.rhtml file:

Actually, I believe the reason it shows and hides the div at all has nothing to do with the statements in the auto_complete field, but in the fact that the ID input field is updated as a result of the auto_complete field, which fires the ID field's AJAX operations. So, the :before and :completes on the auto_complete field do nothing, really.

Okay, forget it. Found the :indicator property. It really bugs me that

a) The consistency between properties and methods on different AJAX- based form helpers is shabby to say the least b) The API documentation on this part of Rails is so sparse. You have to skate around between different classes, and often you don't find the right information for that particular helper derived from some parent class, like in this example, where Google finally served me a page with a description of the :indicator property.

Hm! :slight_smile:

Just for the record, are you aware of the plugin model_auto_completer?

   http://agilewebdevelopment.com/plugins/model_auto_completer

? If you really need both text fields in the interface it won't apply though.

-- fxn

> Basically, this creates two input fields, one where you can put in an > ID of a publisher, and another, where you can write text, and AJAX is > used to fetch publishers whose names contain that text.

Just for the record, are you aware of the plugin model_auto_completer?

   http://agilewebdevelopment.com/plugins/model_auto_completer

? If you really need both text fields in the interface it won't apply though.

Didn't know about that one, no - thanks :slight_smile:

But, as it turns out, I need the user to be able to manually type in the ID and get the corresponding name, and be able to type in a fragment of a name, then get the ID. Besides that, not all my primary keys are integers, so that plugin won't work. This is a seriously specialized app :wink: But I can use that plug on other projects of mine, so thanks for the link!

Daniel

But, as it turns out, I need the user to be able to manually type in the ID and get the corresponding name, and be able to type in a fragment of a name, then get the ID.

OK, yeah the plugin does not help then.

Besides that, not all my primary keys are integers, so that plugin won't work. This is a seriously specialized app :wink: But I can use that plug on other projects of mine, so thanks for the link!

Good. Note however that the plugin does not assume the key is an integer. The key is extracted with a regexp from the ID attribute of LIs. That regexp is "(\d+)$" by default (extract trailing integers), but is configurable.

-- fxn

Ah okay, I just read the doc about trailing integers. Didn't know it was configurable, but that's even better then! :smiley:

Cheers