Search code examples
javascriptjquerywordpress

custom.js only error in homepage (working properly in several pages)


I have some trouble with my wordpress (https://dev.smanegeri1sindang.sch.id/). When I open console, the result like in below.

custom.js?ver=5.4.1:542 Uncaught TypeError: $(...).selectmenu is not a function
    at HTMLDocument.<anonymous> (custom.js?ver=5.4.1:542)
    at i (jquery.js?ver=1.12.4-wp:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
    at Function.ready (jquery.js?ver=1.12.4-wp:2)
    at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)

And when I click search button, the button is not showing and not working. But when I navigate to https://dev.smanegeri1sindang.sch.id/?page_id=58 all error in above it's clear and search button are working properly.

My Question is : What Should I Do and Have any Idea to Fix It ?


Solution

  • .selectmenu() is one of the functions that exist within Jquery-UI, and it exists to modify the native browser select. In the first provided URL you are using a form with select which is invoking this function (You don't have a form in the second provided URL), it seems jquery-ui.js do not exist in your scripts so it will throw an error. Try to add it with WordPress widgets or manually through your HTML like this (you should add v1.11 or above):

    <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
    
    or
    
    <script src="https://dev.smanegeri1sindang.sch.id/wp-includes/js/jquery/ui/selectmenu.min.js?ver=1.11.4"></script>