0

The following code worked flawlessly when added to master code which doesn't contain any jquery script.

<script type="text/javascript" src="http://project.dimpost.com/flexslider-carousel/jquery.js"></script>
<script type="text/javascript" src="http://project.dimpost.com/flexslider-carousel/jquery.flexslider-min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $(window).load(function() {
        $('.flexslider').flexslider({
            animation: "fade",
            animationLoop: true,

        });
    });
});
</script>

But when added to a template which already has jquery element, it gave following two errors in java console.

1.TypeError: $ is not a function

2.Use of getPreventDefault() is deprecated. Use defaultPrevented instead.

Then I modified the code using '$.noConflict();' as:

<script type="text/javascript" src="http://project.dimpost.com/flexslider-carousel/jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
    jQuery(window).load(function($) {
        jQuery('.flexslider').flexslider({
            animation: "fade",
            animationLoop: true,

        });
    });
});
</script>

This again workes flawlessly when added to master code which doesn't contain any jquery script. But when added to the one having already running a jquery, it again shos the same two errors as described above:

1.TypeError: $ is not a function

2.Use of getPreventDefault() is deprecated. Use defaultPrevented instead.

What is the workaround?

Chetan
  • 11
  • 1
  • 10

2 Answers2

0

i don't know accurately but it may work.., if you are using any other script like ajax,Etc it will conflict..., add like this

 var jq = $.noConflict();   
   jq(document).ready(function() {
    jq(window).load(function() {
        jq('.flexslider').flexslider({
            animation: "fade",
            animationLoop: true,

        });
    });
});
0

thanks for the suuport given by you all but congratulate me first (!), the problem is solved. I followed the following steps and the code has started running-

  1. I shifted from https to http (less seure platform, can't help)
  2. Cancelling one of the two jquery libraries, keepping the latest version
  3. and obviously, all that follows here Multiple scripts given here, I tested them all, many do work. :)
Community
  • 1
  • 1
Chetan
  • 11
  • 1
  • 10