2011-07-05 7 views

答えて

1

このコードをこのsite からダウンロードして、そこに記載されている手順に従ってください。 prototype.js、scriptaculous.js、およびAutoComplete.jsファイルだけを含めてください。指示に従って貼り付けをコピーし、URLをassets/ac.php?m=text&s=から?m=text&s=に変更するか、クエリパラメータが1つだけ必要な場合は?s=に変更してください。サーバー側では

<input type="text" id="my_ac3" name="my_ac" size="45" autocomplete="off"/> 
    <script type="text/javascript"> 
    new AutoComplete('my_ac3', '?s=', { delay: 0.25, resultFormat: AutoComplete.Options.RESULT_FORMAT_TEXT }); 
    </script> 

、そのページのビュー機能では、との機能を起動します。

if request.is_ajax(): 
     #match the users input here, perhaps using data from your database and/or regular expressions 
     text = #response text to return, in my case since I chose Options.RESULT_FORMAT_TEXT as my resultFormat, it's a string where each autocomplete item is separated by '\n' 
     return HttpResponse(text, mimetype='text/plain') # mimetype is text here in my case 

が続いてelse節の下に表示する機能の残りの部分を置きます。

関連する問題