ユーザーのマウスがテーブル セルの上に移動すると、ドロップダウン ボックスが html を post 呼び出しによってロードされたデータに置き換えます。これは、ユーザーのマウスの動きが速すぎない場合は正常に機能しますが、速すぎる場合は html が更新されないため、ユーザーがマウスを html 内に戻すと正しくなくなります。
$(".edit_dropdown").bind('mouseenter', function () {
$(this).unbind('mouseenter');
var a = $.trim($(this).html());
var id = $(this).attr('id');
$(this).html("<span id='s-" + id + "'></span>");
$.post('save/dropdown.php', {
id: id,
a: a
}, function (data) {
$("#s-" + id).html(data);
$(".edit_dropdown").bind('mouseleave', function () {
var id = $(this).attr('id');
var a = $("#e-" + id).val();
var dir = $(this).attr('class');
$(this).html(a);
$(this).bind('mouseenter', function () {
$(this).unbind('mouseenter');
var a = $.trim($(this).html());
var id = $(this).attr('id');
$(this).html("<span id='s-" + id + "'></span>");
$.post('save/dropdown.php', {
id: id,
a: a
}, function (data) {
$("#s-" + id).html(data);
});
});
});
});
});
html
<tr>
<td>customer county</td>
<td class="edit_dropdown" id="customer-cust_s_county"><?php echo $row['cust_s_county']; ?></td>
</tr>
$.post ファイルは英国の郡のリストを返します。郡名が html と一致する場合、その郡が選択されたオプションとして返されます。