jQuery Tokeninput: readonly not working

柔情痞子 提交于 2019-12-13 16:29:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!