We all love auto complete. It makes our lives a little less complicated and classy. I decided to (as a complimantry to my new JS beloved framework) to use the JQuery autocomplete plugin, problems began when I needed to use dynamically added text fields with autocomplete. Since the plugin assumes that you use a single and unique DOM ID, was unable to setup the autocomplete feature to newly dynamic fields.
One solution was to add the fields by javascript and Dom manipulation, but I prefered to use a partial in order to keep the code simple and Rubish. The other solution was to add a javascript script tag in the end of the partial which traverses the DOM and adds a unique and random id, and of course setting the auto complete feature for each one of them.
Bottom line, it is working and even working well, but I would like to hear new ideas if anyone has.
Over and out.
Ruby On Rails and a Conning Israeli entrepreneur
Dynamically adding a text field, with autocomplete
Tuesday, October 14, 2008
at
8:55 PM
Posted by
Elad Meidar
Labels:
ajax,
autocomplete,
javascript,
JQuery,
rails 2.0
Subscribe to:
Post Comments (Atom)
Twiters Around
About Me
- Elad Meidar
- I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.
Blog Archive
-
▼
2008 (91)
-
▼
October (24)
- Rails Plugin: Dynamic Session Expiry
- Rails Plugin: import_svn
- Precentage proxy for Ruby's Numeric class
- remote_form_for with no-ajax support
- Tip: Finding all Unread messages in your gmail inbox
- String boolean: MethodMissing fun!
- Simple install Git on Leopard
- Update: Rails 2.1 globalize plugin - Fix
- updated: Brand new Rails security for 2.1
- What is with Mac users?
- Ruby on Rails 2.2 Release Notes
- Lighting Fast Ruby On Rails security checklist
- Google Analytics: Tracking AJAX and Flash
- Tip: 21 Ruby tricks you must use
- ERROR: While executing gem … (ArgumentError)
- Stepping Up: Migrating from an SVN to a Git reposi...
- Tip: Installing Mysql Gem on Leopard
- Javascript logging, all hail to BlackBird
- Free SVN/Git Hosting Services
- IE Testing: Internet Explorer cannot open the Inte...
- 78 Ways For Your Small Business to Save Money
- Dynamically adding a text field, with autocomplete
- My CrunchBase page
- Rails as a default language?
-
▼
October (24)
Labels
- 1.9 (1)
- 2.0 (1)
- 2.2 (1)
- 2.3 (1)
- 2.x (1)
- accessibility (2)
- account (1)
- actionmailer (1)
- activerecord (3)
- adsense (1)
- affiliate (1)
- ajax (3)
- amazon (4)
- analytics (1)
- api (3)
- application (1)
- array (1)
- associations (1)
- attachment_fu (1)
- autocomplete (1)
- aws (2)
- blog (4)
- books (4)
- boolean (1)
- browser (8)
- browsers (3)
- bugs (4)
- buzz (1)
- callback (1)
- callbacks (1)
- caller (1)
- capistrano (1)
- chronic (1)
- class (2)
- classes (1)
- classifieds (1)
- client (1)
- coding (2)
- collboration (1)
- console (2)
- convert (1)
- core (2)
- core. object (1)
- cost (1)
- css (7)
- database (10)
- date (3)
- dating (1)
- db (2)
- debug (2)
- deploy (5)
- deployment (3)
- design (11)
- development (5)
- dojo (1)
- eager (1)
- ec2 (2)
- effects (1)
- elad (2)
- email (3)
- engine (1)
- engineyard (1)
- english (1)
- entrepreneur (1)
- environment (2)
- erd (1)
- error (1)
- example (1)
- expire (1)
- explorer (1)
- extention (1)
- extra (2)
- facebook (2)
- fast (1)
- file (1)
- files (1)
- firefox (4)
- fixtures (1)
- font (1)
- form (1)
- framework (16)
- free (6)
- funny (2)
- gem (7)
- gems (2)
- git (5)
- globalize (2)
- gmail (3)
- google (8)
- graphes (2)
- graphics (1)
- guides (4)
- hacks (1)
- hosting (1)
- html (1)
- http (1)
- ie (5)
- ie8 (1)
- image (2)
- indomite (1)
- install (1)
- iphone (1)
- israel (2)
- javascript (19)
- JQuery (10)
- js (3)
- legacy (1)
- leopard (1)
- lib (1)
- library (3)
- links (2)
- list (1)
- loading (1)
- log (1)
- logger (2)
- logging (1)
- love (1)
- mac (4)
- mail (2)
- manuals (1)
- mapping (1)
- mass (1)
- mephisto (3)
- mercurial (1)
- meta (1)
- metaprogramming (3)
- microsoft (1)
- migrations (2)
- minimagick (1)
- mistake (1)
- mistakes (1)
- model (1)
- money (4)
- mootools (4)
- move (1)
- movies (2)
- music (1)
- mvc (2)
- mysql (2)
- native (1)
- nested (1)
- network (1)
- new (1)
- newsletter (1)
- num_to_english (1)
- numbers (2)
- object (1)
- observer (1)
- ohad (1)
- open (1)
- operators (1)
- optimization (4)
- oracle (4)
- overload (1)
- parse (1)
- pdf (4)
- php (3)
- plugin (11)
- plugins (7)
- programming (4)
- programs (1)
- projects (5)
- prototype (1)
- queries (1)
- rails (50)
- rails 2.0 (10)
- rails 2.1 (6)
- rake (2)
- rants (1)
- record (1)
- reflections (1)
- release (3)
- rendering (1)
- reset (1)
- resize (1)
- rest (1)
- rjs (1)
- ror (1)
- routes (3)
- routes.rb (2)
- ruby (49)
- ruby on bells (2)
- ruby on rails (28)
- ruby-debug (1)
- s3 (2)
- salary (1)
- scaling (2)
- schema (2)
- screencasts (1)
- script (4)
- scripts (1)
- search engine optimization (1)
- security (3)
- seeking alpha (1)
- select (1)
- sendmail (1)
- seo (2)
- sequencer (1)
- sessions (1)
- share (2)
- shell (1)
- site (3)
- site map (1)
- sites (1)
- skype (1)
- social (2)
- source (1)
- source control (4)
- sprites (1)
- sql (1)
- stand alone (1)
- standards (1)
- startup (6)
- storage (2)
- subversion (4)
- svn (1)
- team (1)
- technology (1)
- testing (1)
- textmate (1)
- thread (1)
- time (1)
- tips (45)
- tools (5)
- tracking (1)
- tricks (36)
- tutorials (5)
- ui (4)
- uml (1)
- update (1)
- upgrading (2)
- url (1)
- usability (2)
- user interface (7)
- validations (1)
- vector (1)
- vote (1)
- web (9)
- web services (2)
- web2.0 (4)
- webistrano (1)
- wire (1)
- wwr (1)
- xhtml (1)
- yahoo (1)
- yui (1)
- רובי (8)
- רובי און ריילס (7)
4 comments:
January 29, 2009 at 10:12 AM
I'm about to attempt the same type of thing. Care to share the code you used?
January 29, 2009 at 10:24 AM
Sorry, but the project was delieverd a while ago and i can't access the code anymore.
from what i remember it's pretty simple.
i created a js function that runs right after the dom insert of the new field is being added,
This function traverses the DOM and identifies all the fields from the kind that we added (class="autocomplete_field" for example) and enables the JQuery autocomplete for each of them.
got it?
January 29, 2009 at 10:27 AM
Yes; this is precisely what I was going to try. Glad to hear you were successful with it (and that it was easy :)
January 29, 2009 at 10:35 AM
Great,
don't forget to come back and post a link to your own post.
Post a Comment