| Köteles Zoltán 2007-12-17, 7:07 pm |
| 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
|