Jump to content

[SOLVED] $ Is not a function


Recommended Posts

I am trying to add this code to my prestashop header and the firefox returns me the following error:

 

 

Code used:

<script type="text/javascript">
    $(document).ready(function() {
      $("#owl-demo").owlCarousel({
        navigation : true
      });
    });
</script>

Firefox (Firebug console) error:

TypeError: $(...).owlCarousel is not a function navigation : true

I also tried to include {literal} tags, and with the help of the owner of this script, he found a problem on two jquery libraries but also deleting the other library (or adding the function NoConflict), still not work.

 

Maybe am I missing something on the code?

 

Thnaks!

Edited by Sivo (see edit history)
Link to comment
Share on other sites

If for embed u mean the whole path to the JS it is. And it's fine since in the code the path is correct displaying the JS.

 

@vekia, the js file is included since I can read it by displaying the whole code.

 

 

DEMO (maybe it will help you to understand the problem): ilernaonline.com (you will see the carousel commented to hide it on HTML).

 

Code to find easily the carousel on the demo (search by):

   <div id="owl-demo" class="owl-carousel">
Edited by Sivo (see edit history)
Link to comment
Share on other sites

Hey Vekia,

 

I added the script again without the "navigation: true" and now feedbacks the following error:

ypeError: $ is not a function
	

$(document).ready(function() {

Where is suposed to be the main error? I am checking everything but i can't find the problem since on my static HTML page works, but not there.

Edited by Sivo (see edit history)
Link to comment
Share on other sites

Hi sivo,

 

in your code you have: (line 21)

<script>

  jq1191 =jQuery.noConflict(true);

</script>

 

Not sure if you added this or the theme developer. If the developer did this, this is added to prevent compatibility problems with other javascript libraries that can be loaded. But, in "no-confict" mode, the $ shortcut is not available and the longer jQuery must be used, i.e.

jQuery(document).ready(function ($) {

 

By including the $ in parenthesis after the function call you can then use this shortcut within the code block again.

Hope this helps,

pascal.

  • Like 1
Link to comment
Share on other sites

Hey Pascal, I added the (NoConflict) code by my own, to avoid compatibility problems since the developer of the carousel investigated the code also and said he was facing problems with compatibility with 1.7.2 JQuery library.

 

Thanks you for your time, I'll take a look into your possible solution as soon as posible.

Edited by Sivo (see edit history)
Link to comment
Share on other sites

Hello again Pascal,

 

Adding the following code it does not work

<script>
    jQuery(document).ready(function ($) {
      $("#owl-demo").owlCarousel({
        navigation : true
      });
    });
</script>

Also adding this one with {literal} tags

{literal}
<script>
    jQuery(document).ready(function ($) {
      $("#owl-demo").owlCarousel({
        navigation : true
      });
    });
</script>
{/literal}
Link to comment
Share on other sites

Hello Pascal,

 

Well it seems like NoConflict was crashing my script, so I dont know why but at least it's solved. And it worked with {literal} tags but also it works without them. Could someone explain me what's going on? Because first of all I added the code by default (seems like still default) and did not work.

 

Anyway, thank you all for the help!

Link to comment
Share on other sites

×
×
  • Create New...