Semantic-UI: [Dropdown] - Error behavior "setup menu"

Steps to Reproduce $('#selectID').dropdown('setup menu');

Expected Recreates dropdown menu from select option values.

Result In Console: Uncaught TypeError: Cannot read property 'values' of undefined

Testcase http://jsfiddle.net/agvg0L3j/1/

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Having massive issues with the dropdown module and API as a whole, seems very inconsistent in the current build.

setup menu while undocumented, actually requires an argument with a structure such as this:

$el.dropdown('setup menu', {
            values: [
                {
                    value: '2016',
                    text: '2016',
                    name: '2016'
                },
                {
                    value: '2015',
                    text: '2015',
                    name: '2015'
                }
            ]
        });

Alternatively, replacing the entire html of <select> should cause the dropdown observer to re-render the dropdown module, updating selected value from the new <select> html. It does not update the text tho, for whatever reason. Also it looks like when calling setup menu it actually re-renders twice, not once.

I’m also finding that when using a dropdown that has had setup menu used on it any subsequent calls of .dropdown('get text') work as expected but .dropdown('get value') returns null - anyone else had this… got a fix?

Not sure if the documentation should be changed, or the behavior of setup menu should be changed—the documentation states that the method “recreates dropdown menu from select option values”; I’m assuming any changes to a hidden select should be reflected in an actual dropdown after setup menu is called, does that sound right?

Why should one put those values again?

How can one re-initialise the dropdown on a select after complete overwriting the dropdown with Ajax?