Reputation: 2154
I'm new to jquery mobile. I have a text input in a form which I would like to use autocomplete as a prompt for the user. The user should be able to
I've had a read of the docs at http://view.jquerymobile.com/1.3.2/dist/demos/widgets/autocomplete/ and http://api.jquerymobile.com/listview/#option-filter but there isn't any obvious way to achieve this.
What I would have liked is something like
<input type="text" data-inset="true" data-filter="true" data-filter-reveal="true" data-filter-placeholder="Your car brand">
<li>Acura</li>
<li><a href="#">Audi</a></li>
is there a way to do this using just jquerymobile i.e. no third party plugins?
The example in jquery at http://view.jquerymobile.com/1.3.2/dist/demos/widgets/autocomplete/#&ui-state=dialog
<ul data-role="listview" data-filter="true" data-filter-reveal="true" data-filter-placeholder="Search cars...">
<li><a href="#">Acura</a></li>
<li><a href="#">Audi</a></li>
</ul>
gives (Abbreviated)
<div data-demo-html="true">
<form class="ui-listview-filter ui-bar-c" role="search">
<div class="ui-input-search ui-shadow-inset ui-btn-corner-all ui-btn-shadow ui-icon-searchfield ui-body-c">
<input placeholder="Search cars..." data-type="search" class="ui-input-text ui-body-c">
<a href="#" class="ui-input-clear ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-fullsize ui-btn-icon-notext ui-input-clear-hidden" title="clear text" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="delete" data-iconpos="notext" data-theme="c" data-mini="false">
<span class="ui-btn-inner"><span class="ui-btn-text">clear text</span>
<span class="ui-icon ui-icon-delete ui-icon-shadow"> </span></span></a></div></form>
<ul data-role="listview" data-filter="true" data-filter-reveal="true" data-filter-placeholder="Search cars..." class="ui-listview">
<li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-up-c ui-btn-icon-right ui-li-has-arrow ui-li ui-first-child ui-screen-hidden">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" class="ui-link-inherit">Acura</a>
</div>
<span class="ui-icon ui-icon-arrow-r ui-icon-shadow"> </span>
</div>
</li>
<li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-up-c ui-btn-icon-right ui-li-has-arrow ui-li ui-first-child ui-screen-hidden">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" class="ui-link-inherit">Audi</a>
</div>
<span class="ui-icon ui-icon-arrow-r ui-icon-shadow"> </span>
</div>
</li>
</ul>
</div>
As you can see this turns the list into it's own form. Furthermore the text input field does not have a name or id that can be returned to any encapsulating form. The value is therefore not callable upon form submit.
Upvotes: 1
Views: 7522
Reputation: 1316
You can use jQuery UI Autocomplete on usual jQuery Mobile input field. jQuery UI Autocomplete is one of the widgets that does not conflicts with jQuery mobile. http://jqueryui.com/autocomplete/
Here is the explanation: Getting jQueryUi Autocomplete to work with jQueryMobile
Upvotes: 0