2013년 6월 11일 화요일

[javascript] how to avoid jQuery, Prototype confliction


[javascript] how to avoid jQuery, Prototype confliction


만약 두 프레임워크를 사용해야하는 상황이라면
If you have to use both framework at the same application,

1. 아래와 같은 순서로 두 프레임워크를 불러온다. 
 -  add both framework in order as below

<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="jquery-1.7.1.min.js" charset="utf-8"></script>


2. 아래와 같이 추가하면 $는 프로토타입껄 사용하게 됨!
If you add below, you could use $ as Prototype object.

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

3. 그리고 또 아래와 같이 추가하여 j$를 이용해 jQuery 명령 사용가능!
   Also, if you add below sentence, you could use jQuery thorough j$ variable.

<script type="text/javascript"> var j$ = jQuery; </script>

fin.

댓글 없음:

댓글 쓰기