<script>
$(document).ready(function(){
$("#customer").autocomplete("barcode.php", {
selectFirst: true
});
});
</script>
<script>
$(document).ready(function() {
$("#customer").change(function (e) {
var item = $("#customer").val();
$.post("add", {"data[Sales][item]": item }, function (data) {
$('#details').html(data);
});});
});
</script>
<input type="text" id='customer' name="data[Sales][customer]" class="input-small focused" autocomplete='off'>
<div id='details'></div>
自动填充工作正常。在变化不能正常工作。如果我输入所有文本而不通过autocomplte选择,则onchange脚本正在运行。如果我选择槽自动完成,那么我按Tab键然后onchange不起作用。它没有显示任何结果。
答案 0 :(得分:0)
使用.keypress而不是更改
答案 1 :(得分:0)
您可以使用以下内容:
$("#customer").autocomplete("barcode.php", {
selectFirst: true,
select: function(e, ui) {
alert("selected!");
},
change: function(e, ui) {
alert("changed!");
}
});
$.post("add", {"data[Sales][item]": item }, function (data) {
$('#details').html(data);
});
答案 2 :(得分:0)
var item = $(&#34; #customer&#34;)。val(); ---&GT;改变这里......那就是它。
答案 3 :(得分:0)
如果您使用的是jQuery自动完成插件,请使用其onChange method
实施例
$( ".selector" ).autocomplete({
selectFirst: true,
change: function( event, ui ) {
var item = $("#select01").val();
$.post("add", {"data[Sales][item]": item }, function (data) {
$('#details').html(data);
});
// Add more code here!
}
});