简体   繁体   中英

How to hack jQuery Autocomplete plugin?

I am using jQuery's Autocomplete plugin, and the list of suggestions are generated dynamically. I want to get rid of the filtering provided by the autocomplete function, ie i want to load all the data coming from the backend. code that i am using

$(document).ready(function(){
     $("#search_box").autocomplete("myscript/index");
}

<input type='input' id='search_box' />

PHP backend code (symfony 1.4) At action:

$s = $request->getParameter("p");
$c = new Criteria();
$c->add(DataSkillPeer::SKILLNAME, $s);
$data_array = array();
$data_skill_array = DataSkillPeer::doSelect($c);
foreach($data_skill_array as $arrays)
{
   $data_array[] = $arrays; 
}
$this->display_data = json_decode($data_array, true);

At view:

<?php if(!empty($display_data)): ?>
  <?php foreach($display_data as $da): ?>
        <?php echo $da."\n"; ?>
  <?php endforeach; ?>
<?php endif; ?>

the data is send from the myscript.php file, and i want to load all the data comming from the backend, example if i type j, then the my backend generates java, javascript, jquery, ejb. i want all this data to be displayed without being filtered by autocomplete function like suggestions. is there any way i can hack the autocomplete function to do so without loosing the UI effect it provides.

I got the solution without hacking the autocomplete plugin, as i saw that when i clicked "a" in textbox it queried the backend php script and returned the array ["asp", "asp.net", "actionscript"] and on clicking "s" it didnt fire the backend script as it was taking the data from the cache. hence set the property as {cacheLength: 0} and it worked. Thanks every one for helping me out and your time. and special tanks @JohnP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM