Make Prototype and tokeninput.js files work together

吃可爱长大的小学妹 提交于 2019-12-21 23:41:13

问题


Im using following JS file on my page

https://github.com/loopj/jquery-tokeninput/blob/master/src/jquery.tokeninput.js

but Im also having Prototype.js file attached on same page and first script is not working because of Prototype. Can anyone tell me what changes I need to make using

var $j = jQuery.noConflict(); 

so tokeninput.js can work. Hope someone understand what Im trying to ask. Regards.


回答1:


Hi I was in the same situation but i have found a solution i would like to share with you This is it: 1) Insert your prototype and other library first 2) Insert your jquery library and token input library ex:

<script type="text/javascript" src="js/jquery-tokeninput/jquery.min.js"></script> <script type="text/javascript" src="js/jquery-tokeninput/src/jquery.tokeninput.js"></script>

3)Insert the

<script type="text/javascript">

$.noConflict();
</script>

and

4) Insert the following code and place every other jquery code between the ////

<script type="text/javascript">


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



///////////////////////////////////////////////////////////////////////////////

// Code that uses jQuery's $ can follow here.


///////////////////////////////////////////////////////////////////////////////





});


</script>

I did it and it worked perfectly. I have prototype.js, jquery.js, protoplasm, prototypericheditor, prototip.js all running on the same page and doing their own thing.




回答2:


I think you are going on right track use anything like

    var j = jQuery.noConflict(); 

and then

    j(function() {
    ...
    your token-input code goes here. 
    ...
    });

Post here if that doesn't work.



来源:https://stackoverflow.com/questions/8871430/make-prototype-and-tokeninput-js-files-work-together

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!