(Demo)jquery.ajaxSuggest.1.5.4.js

2012/02/10

=> 日本語版

Contents

  1. Basic usage
  2. Changing the number of displays of candidates
  3. Searching from plurals fields
  4. Submitting at once when selected
  5. Submitting at once when selected (Not enclosed by form tag)
  6. "AND OR" search
  7. Sub-info

Examples

Basic usage

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 );
To contents
Changing the number of displays of candidates

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 } );
To contents
Searching from plurals fields

$('#as03').ajaxSuggest( 'asugg/php/ajaxSuggest.php', { 'database':'2 3' } );
To contents
Submitting at once when selected

$('#as04').ajaxSuggest( 'asugg/php/ajaxSuggest.php', { 'database':3, 'bind_to':'foo' } ) .bind('foo', function(e){ alert($('.as_over').text() + ' is selected.'); });
To contents
Submitting at once when selected (Not enclosed by form tag)

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)'); } });
To contents
"AND OR" search

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

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} );
▲ 目次へ

Author : sutara_lumpur / Blog / Twitter / mail address