I need to show list of items using Jquery tokeninput, have got the list using a json call, but cant figure out if there is a way to set all items to readonly rather than setting individual items explicitly?
Asked
Active
Viewed 1,215 times
1 Answers
1
Are you not able to set the readonly property for each item to true wherever you build the JSON? Or is it an external feed?
Regardless, have you considered using the onResult
callback, as such?
onResult: function (results) {
$.each(results, function (index, value) {
value.readonly = true;
});
return results;
}
Also, note that v1.6.0, obtained from the main download page, does not include readonly functionality - you should download the latest version from Github instead. [Source]
-
when i added readonly property to json it worked, thanks. though onResult did not work. Now I dont get the delete option but can do a backspace and delete an item, setting readonly/disabled on the input box didnt work, any idea? – java1977 Apr 01 '14 at 12:56
-
1Re the onResult: Think I missed out a return statement, try the updated code above. On the backspace, looks like an inconsistency/bug in the library there, setting something to readonly only removes the delete button, and does nothing to stop you deleting the item elsewhere. I suggest adding this line in at the start of the `delete_token(token)` function in the library. `if (token.readonly) return;` – Chris Apr 01 '14 at 13:04
-
I looked at the implementation of the `toggleDisable` and added my own `toggleReadOnly` it's exactly the same except it adds readonly attribute to the input field instead of disabled. – The Muffin Man Oct 29 '15 at 04:36