开发者

Jquery and Prototype Conflict

开发者 https://www.devze.com 2023-01-01 06:29 出处:网络
I am having trouble running two javascript files on the same page. I used JQuery.noConflict() (http://api.jquery.com/jQuery.noConflict/) but no luck.

I am having trouble running two javascript files on the same page. I used JQuery.noConflict() (http://api.jquery.com/jQuery.noConflict/) but no luck.

        <script src="http://www.google.com/jsapi"></script>
        <script>
            google.load("prototype", "1.6.0.3",{uncompressed:false});
            google.load("scriptaculous", "1.8.1",{uncompressed:false});
        </script>
        <script src="js/jquery.tools.min.js"></script>
        <script type="text/javascript">
          $jQuery.noConflict();
          jQuery(document).ready(function($) {
                $("#download_now").tooltip({ effect: 'slide'});
          });

            function show_text() {
            new Ajax.Request('./new.php', {
                             method: 'post',
                             parameters: { userid: $('userid').value },
                             onSuccess: function(r) { $('update').update(r.responseText) }
                                 });    
            }

            document.observe("dom:loaded", function() {

   开发者_开发知识库         $('loading').hide();

            Ajax.Responders.register({
              onCreate: function() {
                new Effect.Opacity('loading',{ from: 1.0, to: 0.3, duration: 0.7 });        
                new Effect.toggle('loading', 'appear');


              },
              onComplete: function() {
                new Effect.Opacity('loading', { from: 0.3, to: 1, duration: 0.7 });
                new Effect.toggle('loading', 'appear');
              }
            });
            });         
            </script>


I believe $jQuery.noConflict(); in your code is a typo. Use jQuery.noConflict();.

Another method to solve your problem is by replacing all $ variables with jQuery (provided that $ is referrring to a jQuery object).


Read this:

  • How to avoid conflict between JQuery and Prototype

or just search stackoverflow like this:

https://stackoverflow.com/search?q=jquery+conflict-prototype


load jQuery first and then call this code:

var $jq = jQuery.noConflict();
//Now you can use $jq in place of $ for jQuery;
$jq(".myButton").css("border","2px");

Load other libraries.

0

精彩评论

暂无评论...
验证码 换一张
取 消