maxwells / bootstrap-tags

Bootstrap-themed jquery tag interface
MIT License
550 stars 134 forks source link

Passing Ids as well as getting Ids #39

Open ghost opened 10 years ago

ghost commented 10 years ago

Hi,

I was wondering if this library supports the ability to pass Ids to each tag as well as getting those passed Ids from the getTags function?

Estentially, what I want to do is pass the tags names and ids for the tags in the initialization. (e.g. $('#tags').tags({suggesstions: [ 'All', 'Accounting', 'Management' ], restrictTo: [ 'All', 'Accounting', 'Management' ], tagIds: [ '1', '2', '3' ] });)

And then would it be possible, using the getTags() function or another function (e.g. getTagIds()), to retrieve those ids as well as the tag names.

This would be very helpful if you could provide a solution for this to me. I would very much like to use this library, but I need it to support Ids.

Thanks!

~ Tyler

maxwells commented 10 years ago

Hi Tyler --

I've thought about this before. I'm hesitant to try and fit that in to the existing code base (it's due for a significant refactor/rewrite). It raises questions for me about how it would support adding new tags (versus just managing existing ones) -- how would it find the id value for a not previously existent tag? I've considered having the library support RESTful conventions for tag saving/loading (when provided a route prefix), but I'm not sold on the idea.

For the time being, could you do something like:

http://jsfiddle.net/FFe2M/1/ (see the bottom of the js portion)

Where you use a tag -> id mapping?