Is it possible to use JQuery and Zepto library at the same time?
Asked Answered
B

2

2
<script src="jsv3/jquery-1.7.1.min.js"></script>
<script src="jsv3/jquery-ui-1.9.2.custom.min.js"></script>
<script src="jsv3/jquery.mobile-events.js"></script>
<script src="jsv3/jquery.ui.touch-punch.js"></script>
<script src="jsv3/turn.js"></script>
<script src="jsv3/jquery.viewport.min.js"></script>
<script src="jsv3/jquery.scraggable.js"></script>
<script src="jsv3/history.js"></script>
<script src='http://vod.hkheadline.com/player/jwplayer/jwplayer.js'></script>
<script src="jsv3/libs/zepto.js"></script>  //  Can not use
<script src="jsv3/zepto.flickable.js"></script>
<script src="jsv3/onload_mobile.js"></script>

Currently I am using several jquery plugins to implement a webapp. I recently find a library call flickable.js and add to the app . However, it use zepto library, so when I add it , it return error of Uncaught TypeError: Object [object Object] has no method 'flickable' , How to fix it? thanks

Bremen answered 8/1, 2013 at 8:0 Comment(0)
P
6

use jQuery's function noConflict.

jQuery.noConflict();

more details here.. http://docs.jquery.com/Using_jQuery_with_Other_Libraries

<script src="jsv3/jquery-1.7.1.min.js"></script>
<script src="jsv3/jquery-ui-1.9.2.custom.min.js"></script>
<script src="jsv3/jquery.mobile-events.js"></script>
<script src="jsv3/jquery.ui.touch-punch.js"></script>
<script src="jsv3/turn.js"></script>
<script src="jsv3/jquery.viewport.min.js"></script>
<script src="jsv3/jquery.scraggable.js"></script>
<script src="jsv3/history.js"></script>
<script src='http://vod.hkheadline.com/player/jwplayer/jwplayer.js'></script>

<script type="text/javascript">
  $.noConflict(false);
</script>

<script src="jsv3/libs/zepto.js"></script>   
<script src="jsv3/zepto.flickable.js"></script>
<script src="jsv3/onload_mobile.js"></script>
Pliable answered 8/1, 2013 at 8:27 Comment(1)
sorry it will affect other function Uncaught TypeError: Property '$' of object [object Window] is not a functionBremen
O
1

you can do this.

jQuery.noConflict();
delete window.$;

and then load the zepto script.

Oxytocin answered 24/9, 2014 at 5:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.