SelectOneMenu: client side function selectValue() doesn't work before menu was opened
See original GitHub issueDescribe the defect When calling the SelectOneMenu widget function selectValue() before the menu was opened at least once, the function call fails.
Uncaught TypeError: Cannot read property 'eq' of undefined
at c.selectValue (components.js.xhtml?…mefaces&v=10.0.0:20)
at <anonymous>:1:45
selectValue @ components.js.xhtml?…mefaces&v=10.0.0:20
(anonymous) @ VM812:1
It seems like this.items
in forms.selectonemenu.js:1114 is undefined in this case.
After opening the menu, everything works fine.
Reproducer Showcase for SelectOneMenu https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml
Environment:
- PF Version: 10.0.0
- JSF + version: MyFaces 2.3.6
- Affected browsers: ALL
To Reproduce Steps to reproduce the behavior:
- Open the SelectOneMenu showcase https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml
- Execute the
selectValue()
function in the console for one of the menus, e.g.
PrimeFaces.getWidgetById('j_idt302:option').selectValue('Option1')
- If you open the menu, e.g.
PrimeFaces.getWidgetById('j_idt302:option').show()
and then execute 2. again, it works.
Expected behavior
selectValue()
should be able to select a value even before the menu was opened.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
get selected value from selectOnemenu using javascript in ...
Open the page in browser, rightclick and View Source (or here on PrimeFaces showcase site). You'll see that the actual <select> element has...
Read more >selectOneMenu and f:selectItem - Prime Community Forum
So basically: how do I create a selectOneMenu that doesn't have an item selected at the beginning and the submit button is only...
Read more >h:selectOneMenu is setting null to bean propert... - JBoss.org
I used h:selectOneMenu inside popup modal panel(rich:popupPanel). Selected value of h:selectOneMenu does't pass to bean property.
Read more >SelectOneMenu | PrimeFaces JavaScript API Docs
When an AJAX call is made and this component is updated, the DOM element is replaced with the newly rendered content. When the...
Read more >h:selectOneMenu javascript onchange problem — oracle-tech
i have 4 <h:selectOneMenu> lists 3 lists depends on the first one via ... <script language="javascript"> function disableOtherLists() { var ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I marked for Elite but its up to @sqores to implement.
Thanks for the quick fix. I just tried it with a build that includes 5a5be48 and the selectValue() function now works as expected.