8.4.2 TypeError: $(...).selectmenu is not a function
Permalink
I don't seem to have luck with select widgets. I have another error in a block: TypeError: $(...).selectmenu is not a function.
view (example strait from jquery-ui site):
controller:
What else am I missing?
Thank you.
view (example strait from jquery-ui site):
<label for="speed">Select a speed:</label> <select name="speed" id="speed"> <option value="Slower">Slower</option> <option value="Slow">Slow</option> <option value="Medium" selected>Medium</option> <option value="Fast">Fast</option> <option value="Faster">Faster</option> </select> <script> $( "#speed" ).selectmenu(); </script>
controller:
public function registerViewAssets($outputContent = '') { $this->requireAsset('javascript', 'jquery'); $this->requireAsset('javascript', 'jquery-ui'); $this->requireAsset('css', 'jquery-ui'); }
What else am I missing?
Thank you.
You are missing an asset. At a guess, something to do with bootstrap menus.
Bootstrap? 'selectmenu' is a jquery-ui widget, not bootstrap's.
OK.
Check the c5 version of jQuery.ui is actually built with that function.
If it is not present, you will need to either provide your own version of ui - dangerous, because it could get in the way core functionality, or create an asset just containing that function and any missing dependencies.
If it is present, the error still means you are missing an asset, so are either not loading it, or trying to use it before it is loaded.
Check the c5 version of jQuery.ui is actually built with that function.
If it is not present, you will need to either provide your own version of ui - dangerous, because it could get in the way core functionality, or create an asset just containing that function and any missing dependencies.
If it is present, the error still means you are missing an asset, so are either not loading it, or trying to use it before it is loaded.