jQuery와 Prototype을 동시에 사용하려고합니다.jQuery와 Prototype 충돌
나는이 문제를 해결하기위한 해결책을 찾기 위해 몇 시간과 시간을 보냈습니다. 내가 찾은 가장 일반적인 방법은 http://docs.jquery.com/Using_jQuery_with_Other_Libraries입니다. 그러나 "jQuery.noConflict()"코드를 어떻게 배치하든 작동하지 않습니다.
아무도 도와 줄 수 있습니까? 여기
사전
에서덕분에 $
함수의 내부 jQuery
객체를 참조, 본질적으로 그렇게
(function($) {
//$.noConflict(); // I don't below this is needed following this pattern
$(function() // shorthand for $(document).ready()
{
$("#example").autocomplete(options);
});
})(jQuery);
처럼 jQuery 코드를 감싸 내 코드
<script type="text/javascript" src="/js/swfobject.js">
</script>
<script type="text/javascript" src="/js/layerswitch.js">
</script>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2351815-2";
urchinTracker();
</script>
<script type="text/javascript" src="/js/jquery-1.3.2.min.js">
</script>
<script type="text/javascript" src="/js/fadeLinks.js">
</script>
<script>
jQuery.noConflict();
jQuery(document).ready(function($){
$("#example").autocomplete(options);
});
</script>
<script src="js/prototype.js" type="text/javascript">
</script>
<script src="js/scriptaculous/scriptaculous.js" type="text/javascript">
</script>
<script src="js/recommended_items.js" type="text/javascript">
</script>
<script type="text/javascript">
//<![CDATA[
Event.observe(window, 'load', function() {
var recommended_items = new RecommendedItems('recommended_items', <?="$store_id, $gift_registry_id" ?>);
recommended_items.setBaseURL('<?=$site_server . SITE_STANDARD ?>');
<?php if (THIS_PAGE == PRODUCT_PHP) { ?>
recommended_items.setProduct(<?="$product_id, $category_id" ?>);
<?php } ?>
recommended_items.fetchItems();
});
//]]>
</script>
jQuery (document) .ready로 전달 된 함수는 호출시 jQuery 객체를 가져옵니다. 따라서 함수 내부에서는 $이어야합니다. – Annan
고마워요. 그러나 아직 끝나지 않았습니다. - " – Kev
@Kev - Firebug로 디버깅 해 봤나? –