abrimo / TinyMCE-Autocomplete-Plugin

Twitter/Facebook style inline autocomplete for the TinyMCE WYSIWYG editor
41 stars 25 forks source link

Is it possible to insert description on select? #10

Closed amitava82 closed 11 years ago

amitava82 commented 11 years ago

I want autocomplete to match key but insert description on select. { "key": "Kattila", "description": "/ The Great Bum" }

zethussuen commented 11 years ago

You need to add the description as a data-element when it's being constructed in the displayOptionList() function first:

matchesList += "<li data-value='" + matches[i].key + "' data-description='" + matches[i].description +  "'>" + matches[i].key.replace(highlightRegex, "$1") + " " + matches[i].description + "</li>";

Then later down in the code in the selectOption() function, you can choose to set current to data-description instead of data-value

zethussuen commented 11 years ago

Or you could go a step further, and add an param called "selected" or something and default it to "value". Next, in the selectOption() function, you would change data-value to "data-" + autocomplete_data.selected. Then, in your tinymce init, add the option of autocomplete_selected : "description",

amitava82 commented 11 years ago

OK, thanks! I'll try it out.