Uncaught ReferenceError: jQuery is not defined

Solved
EmilHolmsten
New Member
1 0 0

Hi! I am trying to create a custom section with the Dawn theme.

 

What I am trying to do is very simple, a date picker, and I have essentially copied the code from online.

 

However, I get "Uncaught ReferenceError: jQuery is not defined" in the console.

Any ideas how to fix it?

 

Thank you.

 

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" defer="defer"></script>

<script>  

  window.onload = function() {
    
    alert( 'window.onload works' );
    
      if (window.jQuery) {
        
        alert( 'window.jQuery does not work' );
        
        let $ = window.jQuery;

        $(function() {
          $("#date").datepicker({
          minDate: +1,
          maxDate: '+2M',
          beforeShowDay: $.datepicker.noWeekends
        });
      });
    }
  }
  
</script>
Accepted Solution (1)

Accepted Solutions
filisantillan
Shopify Partner
12 3 4

This is an accepted solution.

It's because calling JqueryUI instead of Jquery, you would have to add the following line at the beginning.

 

<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"
defer="defer"
></script>

 

By the way, if you're not going to use JqueryUI, you don't need to call it.

Greetings

 
 

View solution in original post

Reply 1 (1)
filisantillan
Shopify Partner
12 3 4

This is an accepted solution.

It's because calling JqueryUI instead of Jquery, you would have to add the following line at the beginning.

 

<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"
defer="defer"
></script>

 

By the way, if you're not going to use JqueryUI, you don't need to call it.

Greetings