0

On my HTML page I have a few select menus which all share the class name .iconDropDownMenu and when the page is generated with PHP some of the select menus will have been hidden by PHP adding another class to the select menu.

Anyway I then wanted to disable only the hidden .iconDropDownMenu which I have been trying to use the following:

$(".iconDropDownMenu:hidden").each(function()
{
    $(this).prop('disabled', true);
});

This runs without no errors but the disabled attribute does not show up on my select menu, thus not disabling input. So I did some research and found that I could use $(this).multiselect('refresh'); inside my .each() above after the first line. However I get an error TypeError: $(...).multiselect is not a function and this is the weird part it actually works, I can see the disabled attribute in the HTML but the error stops the rest of the JavaScript to run...

I also tried using $(this).selectmenu("refresh"); but get the following: Error: cannot call methods on selectmenu prior to initialization; attempted to call method 'refresh' and this also produces the same result, being the disabled attribute to the select menu is added whereas without this it did not before.

I tried to initialize the select menu but it just adds a span to the HTML and messes up select menu by showing the first selection as text outside the select menu?

I also tried to use PHP to output the "disabled" attribute to the select menu HTML but when loaded in the browser it does not show and is removed :/

9
  • Please, what so you mean by will have been hidden by PHP ? but the disabled attribute does not show up on my select menu ? Commented Jul 31, 2016 at 0:29
  • Try to use attr() instead of prop. Commented Jul 31, 2016 at 0:38
  • please share HTML code as well to debug easily Commented Jul 31, 2016 at 0:47
  • I mean that I have basically used PHP to echo out "disabled" in the select HTML <select... disabled></select> but in the browser it does not show up, but if I were to echo out "disabledA" it would show. You know when you press F12 to view code. Commented Jul 31, 2016 at 0:59
  • Sounds like your JS may need to go into a $(document).ready();, here is an example ... jsfiddle.net/kennethcss/vkuhm93s. Without a little more detail though, it's hard to give a more specific answer. Commented Jul 31, 2016 at 1:00

1 Answer 1

1

Sounds like your JS may need to go into a $(document).ready();, here is an example ... https://jsfiddle.net/kennethcss/vkuhm93s/.

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

Comments

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.