Uncaught Referenceerror: Materialize is not defined

Asked

Viewed 1,421 times

1

Eea guys td well? I’m developing a project with Materialize and in this project is giving error in JS, can you help me? I’ll be putting the code next:

<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://demo.expertphp.in/js/jquery.js"></script>
<script src="http://demo.expertphp.in/js/jquery-ui.min.js"></script>

$(document).ready(function() {
  Materialize.updateTextFields();
  $('.sidenav').sidenav();
  $('.fixed-action-btn').floatingActionButton();
  $('select').formSelect();

});
document.addEventListener('DOMContentLoaded', function() {
   var elems = document.querySelectorAll('.fixed-action-btn');
   var instances = M.FloatingActionButton.init(elems, {
     direction: 'top',
     hoverEnabled: false
   });
   });

  • In your example gives the error Uncaught Referenceerror: $ is not defined, because it is importing the Materialize before the jQuery, and the second is a requirement of the first.

  • Enter the jquery first.

  • nothing yet, n is working

  • As of 1.0 alpha, jQuery is no longer a dependency, this is one of the reasons I use Materialize.

1 answer

0


Victor, you’re certainly consulting the wrong version of the documentation. In fact you are again using a version of Materialize and calling the Scripts of the old version!

Note that this is the old documentation link Prefilling Text Inputs Old

But if you’re using the version 1.0.0-rc1 then you need the documentation of this link Prefilling Text Inputs NEW

  $(document).ready(function() {
    M.updateTextFields();
  });

So nay use the Materialize.updateTextFields(); use in his place the

M.updateTextFields(); // opção correta!
  • UGO WAS!! kkkkk thank you very much man, I will pay more attention in the documents agr, sorry for the trouble

  • @Victorgabriel quiet young, the new version of Materialize came out has little time, so it is common to search Google and fall into the old Link. Pay attention tb in Bootstrap that usually gives the same problem. []s

  • Thanks man, I was needing to also take a doubt, have trouble sending me an email to talk better?

  • @Victorgabriel whenever you ask a question and have an answer that suits you consider marking it as accepted by clicking on next to the arrows of the answer you choose. I don’t know exactly if I can help you. But go posting use questions here because if I don’t help you always have someone with more knowledge who will be able.

  • Thank you, Hugo, could you be helping me with a question? I will send you the link here https://answall.com/questions/302819/como-deixaro-return-do-sql-object-laravel

  • @Victorgabriel vixi guy, in this I can’t help you, I don’t know anything back-end, sql, Laravel etc never even moved...

  • ah yes, blz very obg vc is front-end so?

  • @Victorgabriel actually am designe, and I move a little with web. I understand more of CSS, HTML and a little bit of jQuery

  • Can you pass me your Inkedin?

  • @VictorGabriel https://www.linkedin.com/in/hugo-lima-bb145638/

  • I need the email

  • @VictorGabriel [email protected]

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.