Kaidul
Kaidul

Reputation: 15855

Jquery Mobile - Option is not added dynamically

I am using jquery mobile latest version. I have a select field that actually look like this:

<select id="make">
</select>

I want to dynamically added option on it.So I use this code :

var makeArr = new Array(1, 2, 3, 4, 5);
var parent = $('#make');
$.each(makeArr, function(i, item){
   parent.append('<option value="' + item + '">' + item + '</option>');
});

I have also use parent.append('<option value="' + item + '">' + item + '</option>').trigger('create'); but nothing change.

I have added <li> under <ul> by this way.But this is not working here.

Upvotes: 0

Views: 51

Answers (1)

take
take

Reputation: 2222

try

$("#make").selectmenu('refresh', true);

after inserting dynamic content.

Upvotes: 1

Related Questions