我有一個問題與JQuery 1.3.0移動自動完成,因爲我不知道如何選擇一個列表項並將選擇添加到不同的DIV或隱藏的輸入字段! 這裏是我的代碼:jquery手機自動完成選擇選項
$(document).on("pageinit", "#main", function()
{
$("#addimageword").on("listviewbeforefilter", function (e, data)
{
var $ul = $(this),
$input = $(data.input),
value = $input.val(),
html = "";
$ul.html("");
if (value && value.length > 2) {
$ul.html("<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>");
$ul.listview("refresh");
$.ajax({
type : 'GET',
url: "./inc/search2.php",
dataType: "json",
data: {
q: $input.val()
}
})
.then(function (response) {
$.each(response, function (i, val) {
var substr = val.split('_');
var idword = substr[0];
var your = substr[1];
var lblyour = substr[2];
var learn = substr[3];
var lbllearn = substr[4];
var lblyourlang = substr[6];
var lbllearnlang = substr[7];
html += "<li><a href='#'>" +lblyour+": "+your+" - "+lbllearn+": "+learn+ "</a></li>";
});
$ul.html(html);
$ul.listview("refresh");
$ul.trigger("updatelayout");
});
}
});
$('#addimageword li a').click(function(){
var listItemText = $(this).text;
$('#result').text(listItemText);
$('#addimageword').children('li').hide();
$('#addimageword').bind(function(){
$.mobile.listview.prototype.options.filterPlaceholder = listItemText;
});
e.preventDefault();
})
<ul id="addimageword"
data-role="listview"
data-inset="true"
data-filter="true"
data-filter-placeholder="Type in your word" data-filter-theme="d">
</ul>
<div id="result">
</div>
有誰知道它是如何工作的?
感謝的提前...
你解決這個問題?我有同樣的問題,我的列表返回,但我如何選擇和填充ul \輸入? – 2013-03-28 20:19:33