Frage

I'm trying to hook acts_as_taggable_on to tag-it to have a nice autocomplete effect for the various tags.

I've set both these up and it seems to work quite nicely. The only thing I cannot get to work yet is the autocomplete.

Tag-it takes an array of values for the autocompletion bit, as such:

$("#myTags").tagit({
    availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"]
});

1) I cannot figure out how to send a rails variable containing an array to availableTags

2) Another problem is that the acts_as_taggable_on does not supply a method for returning all the tags (Tag.all or something) so it's making it more difficult to pass in an array of values for the autocomplete to work.

Any ideas on these two points? Thanks!

War es hilfreich?

Lösung

1) You could try the gon gem. See http://railscasts.com/episodes/324-passing-data-to-javascript

2) ActsAsTaggableOn::Tag.all

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top