Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Why am I getting the error 'material_select is not a function'

boyokendall free asked 5 years ago


I have tried to use the material-select in my application but I'm getting an error of:

TypeError: $(...).material_select is not a function

I am using the pro version of MDB (version 4.8.11). Here is the script and CSS arrangement.

<head>
      <link rel="stylesheet" href="~/lib/mdb/css/mdb.min.css" />
      <script src="~/lib/mdb/js/mdb.min.js"></script>
      ...
</head>

I thought perhaps there was something wrong with the script and so I changed to the 'dist' folder to see if that helped but it didn't.

<head>
    <link rel="stylesheet" href="~/lib/mdb/dist/css/mdb-pro.min.css" />
    <script src="~/lib/mdb/dist/js/mdb.min.js"></script>
</head>

At the foot of my page I have the following code:

<body>
...
     <script>           
            $(document).ready(function () {
                $(".button-collapse").sideNav();
                $('.mdb-select').material_select();
            });
    </script>
</body>

Am I doing something wrong here?


lemons free commented 5 years ago

you have to write: $('.mdb-select').materialSelect();


cdenby pro answered 4 years ago


It would be great if MDB would provide an alias for us to be able to still use material_select() and have the method just call materialSelect(). This is a real hassle when you have to make major changes to scripts because of an MDB version change! I'm in the process of splitting an old app into a sub-app and the javascript is filled with "material_select". It's making for a lot of time to convert it all to the new format of the method name.


Bartłomiej Malanowski staff commented 4 years ago

We've changed material_select() in favor of materialSelect() in MDB 4.5.9. Then, we've informed that old syntax can still be used, but will be deprecated soon. This happened in 4.8.11. The old, deprecated syntax won't be supported again.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.11.0
  • Device: PC
  • Browser: Firefox
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No