How do I store additional field value data?
How do I store additional field value data?
I'm writing a typeahead plugin, in which the user's input into the input field is used to present a set of matching items from a key->value list (e.g. {'id' : '1',' text' : "dog"}, {'id' : '2', 'tex' t: "cat},...). The plugin will autocomplete the users selection, filling the editor form field with the text portion. However, I also need to store the id value (hidden from the user of course).
I thought about storing it as an extra value in the editor's data property, a la ajax.data, but this doesn't seem to be created until the form is being prepared to be submitted (Am I wrong about this?!!!). In any case, where could I store a bit of extra data as the field is being edited? (I know I could set a cookie but maybe there's a cleaner way). Thanks very much in advance!
This question has an accepted answers - jump to answer
Answers
A couple of options:
conf
parameter (passed in as the first parameter to all field plug-in methods) and give it a name that doesn't conflict with any of the built in names (use double underscore to start the parameter name for example).<input type="hidden">
field into the DOM when it creates its DOM elements which could be used to store the datamyInputEl.__myId = 1;
for example).Allan