VaTo
VaTo

Reputation: 3098

How can I reset dropdowns in jQuery mobile

I found this post in how to reset dropdowns in jQuery, which works great but when I select jquery mobile doesn't work anymore. This is my jsfiddle code: http://jsfiddle.net/TmJCE/684/

<form>
    <select id="name" >
    <option value="">select all</option>
    <option value="1">Text 1</option>
    <option value="2">Text 2</option>
    <option value="3">Text 3</option>
</select>

<select id="name2" >
    <option value="">select all</option>
    <option value="1">Text 1</option>
    <option value="2">Text 2</option>
    <option value="3">Text 3</option>
</select>
    <a data-role="button" data-inline="true" onclick="$('#name').prop('selectedIndex',0);">Cancel</a>
</form>

Any ideas in how to accomplish this?

Upvotes: 0

Views: 324

Answers (1)

Sushil
Sushil

Reputation: 2835

What you should do is set the value of the dropdown to ''

Try this

$('#name2').change(function(){
    $('#name').val('').selectmenu('refresh');
});


$('#name').change(function(){
    $('#name2').val('').selectmenu('refresh');
});

Here's a working JS Fiddle.

Upvotes: 1

Related Questions