问题
I'm using the plugin found at http://loopj.com/jquery-tokeninput/ in a field which creates a list of users with admin access to a web application.
Searching, adding and removing users works perfectly.
However, I want to use the 'readonly' functionality to stop people removing themselves from the list (which would cause an issue since they wouldn't be able to see the page).
The plugin suggests adding the "readonly" : true
attribute to the JSON which sets the page up. I have done this but I am still able to remove myself.
This is the function generated. Can anyone see what's wrong with it?
$("#admin_users").tokenInput("/people/select", {
prePopulate: [
{
"id": 1,
"name": "Kevin Hughes",
"readonly": true
}, {
"id": 3,
"name": "Caroline Hughes",
"readonly": false
}
]
});
As I say, apart from the readonly
bit, it works fine.
Extra info: I'm also using Bootstrap on the page. Could this have any interaction?
回答1:
It turns out that the code you get from download link on the web page at http://loopj.com/jquery-tokeninput/ doesn't actually support this feature, even though it's in the documentation on the page, the download link says "latest" and the version number is the same as the latest commit in their repo.
I downloaded a newer version from their GitHub https://github.com/loopj/jquery-tokeninput and it now works fine.
来源:https://stackoverflow.com/questions/13364161/jquery-tokeninput-readonly-not-working