通常の静的なhtml/phpページを使用している場合、オートコンプリートは正常に動作します。jquery autocomplete ajaxから生成する場合の作業なし
しかし、ダイナミックにロードするモジュール(AJAX)で、同じHTMLをエリアに生成しています。私はオートコンプリートを動作させることができません。
これをどのように解決できますか?私はどこでも検索し、すべてを試しましたが、明らかに適切な解決策ではありません。
//
// this is the ajax code load dynamic contents in a #display_area
// from onclick=selected_purchase()
//
function selected_purchase() {
var fields = $(":input").serialize();
$.ajax({
url: "purchase4",
type: "POST",
dataType: "html",
data: fields ,
beforesend: function(a) {
// before send process here
showBusy();
},
success: function(html) {
// success process here ...
processForm(html);
}
});
}
//
// this is the autocomplete code
//
$("#supplier").autocomplete({ //the recipient text field with id #supplier
source: function(request, response) {
$.ajax({
url: "search_supplier",
dataType: "json",
data: request,
success: function(data){
if(data.response == 'true') {
response(data.message);
}
}
});
},
minLength: 2,
select: function(event, ui) {
// Do something extra on select...
// add user id to hidden input
$('input[name="name"]').val(ui.item.value);
$('input[name="sl"]').val(ui.item.sl_id);
return false;
},
});
あなたのコードを見ずに手助けするのは難しいですが、これまでの投稿を投稿することはできますか? –
おかげで、いくつかのコードが追加されました。 –