I am working on jquery multiple autocomplete, however, while i type something, all the items are published instead of the matching ones. My Javascript is
$('.tags').bind("keydown", function(event) {
if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) {
event.preventDefault();
}
}).autocomplete({
source : function(request, response) {
$.getJSON($.cookie('base_url') + "js/getaddressbook.php", {
term : extractLast(request.term)
}, response);
},
search : function() {
var term = extractLast(this.value);
if (term.length < 2) {
return false;
}
},
focus : function() {
return false;
},
select : function(event, ui) {
var terms = split(this.value);
terms.pop();
terms.push(ui.item.value);
terms.push("");
this.value = terms.join("; ");
return false;
}
});
The js/getaddressbook.php returns
["gunjan.soni","askhr","saurabh.burman","Aditi.Nehra","ithelpdesk","shipra.kwatra","gagandeep.manchanda"]
Not sure where am i going wrong.
Below is the snapshot how it looks like
Please help!
My JS controller has the function
Public function getaddressbook() {
$this -> load -> model('common_model');
$data = $this -> common_model -> addressbook();
echo json_encode($data);
}
And the common_model has the function
Public function addressbook()
{
$this -> db -> select('emailid');
$this -> db ->where('emailid <>','');
$result = $this -> db -> get('addressbook');
if ($result -> num_rows() > 0)
{
foreach ($result->result() as $row)
{
$data[] = $row -> emailid;
}
return ($data);
}
else
{
return FALSE;
}
}