Make Prototype and tokeninput.js files work together

394 Views Asked by At

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.

2

There are 2 best solutions below

5
On

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.

0
On

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.