在进入不改变输入值JQueryMobile自动完成点击 [英] JQueryMobile autocomplete click on entry dont change input value
问题描述
我试图让使用jQuery Mobile自动完成一个输入。
所以,我发现这个在这里演示:
http://demos.jquerymobile.com/1.4.0/listview-autocomplete-远程/
但我的问题是,我无法通过点击进入上市更改输入字段的值。
我想,如果我点击一个条目列出输入字段的值上像正常的自动完成问题的项目的价值。
下面是一个SSCCE(我不能把页面上的jsfiddle工作,所以我用引擎收录):
感谢您的帮助。
这是多还是少一样在这个<一个href=\"http://stackoverflow.com/questions/17980018/autocomplete-in-jquery-mobile-text-input\">link.
在您的code,你使用。就绪()
而不安装点击
事件动态生成里
。 。就绪()
不建议JQM使用,而是使用的 jQuery Mobile的1.4事件的。
等效事件。就绪()
是 pagecreate
,因为它替换 pageinit
在JQM 1.3.2及以下。
的$(document)。在(pagecreate,#startseite功能(){ / *从李点击文本检索* /
$(文件)。在(点击,礼,函数(){
变种文字= $(本)的.text();
$(本).closest(UL)preV(形式)找到(投入)VAL(文本)。;
}); $(#自动完成)。在(filterablebeforefilter功能(即数据){
/ * code *的休息/
});
});
块引用>I try to make a autocomplete input with jquery mobile. '
So I found a demo for this here: http://demos.jquerymobile.com/1.4.0/listview-autocomplete-remote/
But my problem is, that I cant change the value of the input field by clicking on a listed entry.
I want that if I click on a listed entry the value of the input field gets the value of the entry like the normal autocomplete behavior.
Here is a SSCCE (I couldnt bring the page to work on jsfiddle so I used pastebin):
Thanks for any help
解决方案It is more or less the same as in this link.
In your code, you're using
.ready()
and not attachingclick
event to dynamically generatedli
..ready()
isn't recommended to be used in jQM, instead, use jQuery Mobile 1.4 events.The equivalent event to
.ready()
ispagecreate
as it replacespageinit
in jQM 1.3.2 and below.$(document).on("pagecreate", "#startseite", function () { /* retrieve text from clicked li */ $(document).on("click", "li", function () { var text = $(this).text(); $(this).closest("ul").prev("form").find("input").val(text); }); $("#autocomplete").on("filterablebeforefilter", function (e, data) { /* rest of code */ }); });
这篇关于在进入不改变输入值JQueryMobile自动完成点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!