【发布时间】:2012-05-01 22:54:21
【问题描述】:
jquery 自动完成选择事件后的简单文本字段更改。我想拆分数据并将其显示在其他文本字段中。我正在尝试这个。这根本不会改变任何值。我需要在这里改变什么?
$(function() {
$("#term").autocomplete({
source: function (request, response) {
$.post("/users/search", request, response);
},
minLength: 2,
select: function(event, ui){
$('#div2').html(ui.item.value); #doesn't populate with new text.
document.getElementById('#found').value="test"; #for test
} #doesn't populate with new text.
#I want selected data to go here in the 'found' element id
});
});
Ruby/html -
<%= text_field_tag :found, nil, :maxlength => 11, :size => 20%>
<input id="found" maxlength="11" name="found" size="20" type="text" />
【问题讨论】:
-
#found是什么类型的元素? -
@AndrewWhitaker - 文本字段。
<%= text_field_tag :found, nil, :maxlength => 11, :size => 20%> -
select事件是否会触发?在处理程序中放置alert会发生什么? -
@AndrewWhitaker - 是的 - 确实如此。如果我将其更改为 html
<a id="found"></a>,那么它会很好地填充。 -
它填充到 a 和 p 标签。但不输入标签。
标签: javascript jquery