2012/02/10
=> 日本語版
First parameter => File name transmitted by Ajax
Second parameter => Array number in the file of PHP
【jQuery】
$('#as01').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{'database':2}
);
【ajaxSuggest.php】
$db_settings = array(
...
array('table'=>'nations', 'field'=>'name', 'order'=>'id'), //2
array('table'=>'users_en', 'field'=>'name', 'order'=>'id') //3
);
Use 'limit' option.
By the way, if "field" is same as "order", You can omit "field".
$('#as02').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{
'database':3,
'limit':20
}
);
$('#as03').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{
'database':'2 3'
}
);
$('#as04').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{
'database':3,
'bind_to':'foo'
}
)
.bind('foo', function(e){
alert($('.as_over').text() + ' is selected.');
});
If text box is not enclosed by form tag and event handler is set
for inputting enter key, when one of the list is selected by enter key
function is doubly executed.
To avoid this situation, a argument that become true when selected by
enter key is set When originality event of plugin is fired.
$('#as05').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{
'database':3,
'bind_to':'foo'
}
)
.bind('foo', function(e, is_enter_key){
if(!is_enter_key){
alert($('.as_over').text() + ' is selected. (by mouse)');
}
});
$('#as05').keydown(function (e){
if(e.keyCode == 13){
alert($('#as05').val() + ' is selected. (by enter key)');
}
});
Default search type is "AND".
var andor06 = null;
function as06(){
$('#as06').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{'database':2, 'and_or':andor06}
)
}
as06(); //First setting.
$('[name="radio06"]').change(function(){
andor06 = $(this).val();
$('#as06').empty();
as06(); //Set again.
});
Sub-info displays right side of list.
Choose array number as well as 'database' option.
【jQuery】
$('#as07').ajaxSuggest(
'asugg/php/ajaxSuggest.php',
{'database':2, 'sub_info':2}
);