POSTリクエストを送信し、現在のhtml本文を応答本文に置き換えます。問題は、マウスクリックで入力テキストがクリアされず、オートコンプリートが利用できないことです。
オートコンプリートライブラリを使用しています。
このコードは、本文に変更を加えずにサーバーからの応答である場合に機能します。
これは関連するコードです:
$(document).ready(function() {
$('input, textarea').each(function () {
if ($(this).val() == '') {
$(this).val($(this).attr('Title'));
}
}).focus(function () {
$(this).removeClass('inputerror');
if ($(this).val() == $(this).attr('Title')) {
$(this).val('');
}
}).blur(function () {
if ($(this).val() == '') {
$(this).val($(this).attr('Title'));
}
});
};
window.onload = function()
{
$("#search_type").autocomplete("/company/autocomplete/",{
minChars: 2
});
};
これは機能しているように見えますが、値をクリックした後に常に実行されるぼかし機能は明確ではありません。
$('input, textarea').live('click',function() {
// CLEAR INPUT VALUE ---------------------------------------------------------------------------------------------------
$('input, textarea').each(function () {
if ($(this).val() == '') {
$(this).val($(this).attr('Title'));
}
}).focus(function () {
$(this).removeClass('inputerror');
if ($(this).val() == $(this).attr('Title')) {
$(this).val('');
}
}).blur(function () {
if ($(this).val() == '') {
$(this).val($(this).attr('Title'));
}
});
});