1

I am using filamentgroup jquery selectmenu(), I am calling it on the dynamically built selectlist and on the selectlist which is already built but options are addying dynamically like:

First case

        $("presentselectlist").selectmenu();      //present selectlist initialized

        $("presentselectlist").html("<option></option>.."); // addding options dynamically 

        $("presentselectlist").selectmenu();  // then reinitilaized, but not working this line

second case

        var newselectlist = $("<select ..."); // creating new selectlist dynamicallly

        $(newselectlist).selectmenu();      // then initialized it by selectmenu but not working

1 Answer 1

2

In order to alter the options in a selectmenu you'll need to disable it, alter the <select> to your liking, destroy it, then recreate it.

$('select')
    .selectmenu()
    .selectmenu('disable')
    .append($('<option></option>').attr('value', 'Tiger').text('Tiger'))
    .selectmenu('destroy')
    .selectmenu();

Live Example - http://jsfiddle.net/kpMkw/1/

This is not ideal but it will work.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much. I spent an entire weekend searching for solutions to this. Found several posts, but none worked. No one seemed to mention that you need to "disable" the damn thing before appending new options. Just minor syntax errors above (but you have them fixed in your jsfiddle).
Glad I could help. I updated my post to fix the syntax issue, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.