<link href= "${ctxstatic}/jquery-select2/4.0.3/select2.min.css" rel= "stylesheet"/>
<script src= "${ctxstatic}/jquery-select2/4.0.3/select2.full.min.js" type= "Text/javascript" ></script>
<script src= "${ctxstatic}/jquery-select2/4.0.3/i18n/zh-cn.js" type= "Text/javascript" ></script>
$ ("[data-toggle= ' tooltip ']"). ToolTip ({html:true});
Get the entire list
$ (' #primaryAuditUserId '). Select2 ({
Language: "ZH-CN",
Minimuminputlength:1,
PLACEHOLDER: "--Please enter the nickname search--",
Ajax: {
URL: "Xxx/xxx/xxxx/userall",
DataType: "JSON",
DELAY:500,
Data:function (params) {
Return {Name:params.term};//name is the ID of the incoming parameter
},
Processresults:function (res, params) {
var options = [];
Console.log ("Res:" +res);
$ (res). each (function (index, R) {
var option = {"id": r.id, "text": ID in r.name};//list, name in list
Options.push (option);
});
return {
Results:options
};
},
Escapemarkup:function (m) {
return m;
}
}
});
Get ID
(function () {
var id = $ ("#select2-userid"). Val ();
if (ID) {
$.get ("xxxxxx/xxxx/single/" + ID, function (result) {
if (result) {
$ ("#primaryAuditUserId"). HTML ("<option value=" + result.id + "' >" + result.name + "</option>");//
}
});
}
})();
<li>
<label>:</label> of the first trial person
<input type= "hidden" id= "Select2-userid" value= "${infodto.primaryaudituserid}"/>
<form:select path= "Primaryaudituserid" class= "Input-medium" ></form:select>
</li>
Interface:
Fuzzy matching list
@RequestMapping (value= "Userall")
@ResponseBody
Public list<user> getusers (String name) {
User User=new user ();
User.setdelflag ("0");
User.setname (name);
List<user> userlist=userdao.findlist (User);
if (userlist.size () <=0| | Userlist==null) {
return null;
}
return userlist;
}
Querying for individual IDs
@RequestMapping (value= "Singuser")
@ResponseBody
public string Getsingleuser (string name) {
User User=new user ();
User.setname (name);
User User_=userdao.getsingle (user);
return User_.getid ();
}
JQuery Ajax Get Info Show in drop down list