0

I'm trying to hide and show a multiselect picklist field on a Visualforce page based on the picklist value of another field, however the jQuery show() function seems to mess with the rendering of the multiselect. When it renders, instead of the normal boxes side-by-side with arrows in between, it also displays a picklist like box above with the selected values in gray.

I have an id on the multiselect field (which is just an apex:inputField) and I'm calling the jQuery show and hide methods on that id: j$('[id*=idOfMultiselect]').show(); If I just render the multiselect and then call .hide(), it disappears, but then calling .show() brings up that weird extra box.

  • Would you be able to add a Minimum Viable Reproduction (MVR)? A small amount of code anyone could drop into their org would make it much easier to identify your issue. – Adrian Larson Jul 18 '17 at 18:33
  • Hey Adrian, I have an id on the multiselect field (which is just an apex:inputField) and I'm calling the jQuery show and hide methods on that id: j$('[id*=idOfMultiselect]').show(); If I just render the multiselect and then call .hide(), it disappears, but then calling .show() brings up that weird extra box. – McD Jul 18 '17 at 18:36
  • Please edit your post with any clarifications. That's not what comments are for! (and many people don't read comments) – Adrian Larson Jul 18 '17 at 18:37
1

So after a bit of digging, I realized that Salesforce renders only one piece of the multiselect - the . There is also a hidden element that they don't display. If you use a jQuery selector to get the id of the multiselect element and hide() then show(), it will grab and reveal both of these elements (displaying the ugly select box).

I got around this by using j$('[id*=idOfMultiselect]').siblings().show() which only displays the table, not the select, which should remain hidden.

  • This Q&A would be significantly more useful to the community if you edit this answer (and the question) to include code which illustrates the point. – Adrian Larson Jul 19 '17 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.