问题描述:

I have a new application that contains a Modela called "Campaigns". Each campaign is able to have any number of tags associated with it.

What I am attempting to do is impliment a Stack Overflow-like behavior with these tags. Namely, that when you create a new campaign, it gives you a text-field that will auto-complete with tags that already exist, and start anew every time you put a space. Additionally, should the tag not exist, it should create a new tag.

This railscast is a step in the right direction, but it only allows for one "tag" at a time.

Can anyone point me in the right direction?

网友答案:

In the model layer I'd go for a plugin like: https://github.com/mbleigh/acts-as-taggable-on.

In the view you want an autocomplete plugin (personally I use this http://docs.jquery.com/Plugins/autocomplete). Then either generate a controller for the tags and fetch the autocomplete list remotely or just = them in the page.

相关阅读:
Top