HTML:
<link rel="stylesheet" href="token-input-facebook.css" />
<script src="jquery.tokeninput.js"></script>
<br/><label for="ExpFilter">Expl:</label><br/>
<input type="text" id="ExpFilter" style="width:100px"/>
jQuery:
var Code_Expl = [
{ id: 0, name:"+ DESIGNATED CONTRACTING STATES:"},
{ id: 1, name:"+ EXTENSION OF THE EUROPEAN PATENT TO"},
{ id: 2, name:"+ REQUEST FOR EXAMINATION FILED"},
{ id: 3, name:"+ PAYMENT OF DESIGNATION FEES"},
{ id: 4, name:"+ FIRST EXAMINATION REPORT"},
{ id: 5, name:"- LAPSED IN A CONTRACTI...FROM NAT. OFFICE TO EPO"},
{ id: 6, name:"+ EUROPEAN PATENT GRANTED"},
{ id: 7, name:"+ ENTRY IN THE NATIONAL PHASE"},
{ id: 8, name:"BE: CHANGE OF HOLDER'S NAME"},
{ id: 9, name:"CORRESPONDS TO:"},
{ id:10, name:"+ EUROPEAN PATENTS GRANTED DESIGNATING IRELAND"},
{ id:11, name:"- PATENT CEASED"},
{ id:12, name:"- FR: TRANSLATION NOT FILED"},
{ id:13, name:"+ NO OPPOSITION FILED"},
{ id:14, name:"- PATENT LAPSED"},
{ id:15, name:"+ POSTGRANT: ANNUAL FEES PAID TO NATIONAL OFFICE"},
{ id:16, name:"- BE: LAPSED"},
{ id:17, name:"- GB: EUROPEAN PATENT C...-PAYMENT OF RENEWAL FEE"}
];
作品:
var query = "+ DE";
var results = $.grep(Code_Expl, function (row) {
return row.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
});
console.log(results);
// ---------------------
WORKS,但不适用于以 PLUS 开头的内容 - 为什么?我使用上面相同的 grep 似乎是填充函数失败但我不明白为什么
$(document).ready(function() {
$("#ExpFilter").tokenInput(Code_Expl,{theme: "facebook"});
});