QF_Livesearch

From: Date: Mon, 17 Dec 2007 13:30:10 +0000
Subject: QF_Livesearch
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28334@lists.php.net to get a copy of this message
Hello, I'd like to use QuickForm_Livesearch, but I always got an error. auto_server.php: include_once 'includes/config.paths.php'; include_once 'HTML/AJAX/Server.php'; class LiveServer extends HTML_AJAX_Server { var $initMethods = true; function initLivesearch() { include_once 'includes/class.Livesearch.php'; $this->registerClass(new livesearch()); } } $server = new LiveServer(); $server->registerJSLibrary('QfLiveSearch', 'live.js', $libs_dir.'/'.$pear_dir.'/HTML/QuickForm/'); $server->handleRequest(); class.Livesearch.php file: class livesearch { var $livesearch; function getPublisherNames() { global $mdb2; $query = " SELECT p.publisher_id AS publisher_id, p.publisher_name AS publisher_name FROM Publishers AS p WHERE p.is_deleted = '0' ORDER BY p.publisher_name "; $result =& $mdb2->query($query); while ($row = $result->fetchRow()) { $this->livesearch[$row['publisher_id']] = $row['publisher_name']; } } function getPublisherName($input) { $ret = array(); $this->getPublisherNames(); foreach($this->livesearch as $key => $value) { if (stristr($value,$input)) { $ret[$key] = $value; } } return $ret; } } and my QF element: $form->addElement('livesearch_select', 'publisher_id', $locale->get('publisher'), array( 'elementId' => 'getPublisherName', 'callback' => array('livesearch', 'callbackPublisherNames'), 'searchZeroLength' => 1, 'buffer' => 350, 'printStyle' => 1, 'autoComplete' => 1 ), array('size' => '50') ); And the error: remoteLiveSearch.getPublisherName is not a function This is the function that generated by livesearch: <script type='text/javascript'>//<![CDATA[ callback = {}; function searchRequest(searchBox, callfunc) { eval("remoteLiveSearch."+callfunc+"(searchBox.value)"); } //]]> </script> Path is OK. If I'm using a simple ajax request working perfectly. What's wrong with my script? Thanks a lot ZoTya

« previous php.pear.general (#28334) next »