jquery - cakePHP dynamicaly adapting input JqueryUI suggestions how? -
i'm trying input suggestions. in it's self nothing special jqueryui able pretty out of box...
where ran trouble providing jqueryui list of possible suggestions need provide... table use big dumped whole view... can't figure out how thake value user starts type field , give him first 100 suggestions remain... hope reduce load on db , speed loadtime of page because cakephp doesn't have pack whole table view each time user requires form!
the code have far: (every helping hand appreciated! thx...) controller:
<?php app::uses('appcontroller', 'controller'); class locationsmanagercontroller extends appcontroller { public $helpers = array('js'); public $components = array('requesthandler'); public function index() { } public function updatesuggestions() { /* * place passed value $locationname */ $this -> loadmodel('location'); if ($this -> requesthandler -> isajax()) { $this -> location -> find('list',array( 'limit'=>'100', 'conditions' => array('location.name' => $locationname), )); $this->render('suggestions'); } /* * tell jqueryui update it's suggestion array... */ }
} ?>
view: index.ctp
<div id="suggestions"> <!-- array of possible options... --> </div> <?php echo $this -> html -> script('jqueryui', false); echo $this -> form -> create('locationsmanager'); echo $this -> form -> input('location', array('id' => 'location')); echo $this -> form -> submit('send'); $updatesuggestions = $this -> js -> get('#location') -> event( #@formatter:off ; 'change', $this->js->request( array( 'action' => 'foo', 'data' => $form, ), array( 'async' => true, 'update' => '#suggestions' ) ) #@formatter:on ; ); ?>
is best method this? thx help!!
as using jueryui can use autocomplete:
http://jqueryui.com/autocomplete/#remote
then in controller have create action returns json list of suggestion.
Comments
Post a Comment