2015-10-18 2 views
-1

Пробовал разрешить конфликт JQuery между библиотеками JQuery 1.8.2 & 1.4.4 со всеми методами, описанными в различных потоках Stackoverflow. Но тщетно.Контекст библиотеки JQuery - не удалось решить

<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script> 
<script src="js/fshare.js" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $('#floating-bar').fshare({ theme: 'compact', upperLimitElementId: 'upper-limit-element', lowerLimitElementId: 'lower-limit-element' }); 
    }); 
</script> 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> 
<script>window.jQuery || document.write('<script src="./js/jquery-1.8.2.min.js">\x3C/script>')</script> 

Ссылка для fshare.js: http://egrappler.com/jquery-floating-social-share-plugin-floatshare/

+0

Проверьте это - https://api.jquery.com/jquery.noconflict/ –

+0

Возможная дубликация [Можно ли использовать несколько версий jQuery на одной странице?] (Http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same- страница) –

ответ

0

Здесь решение для Jquery конфликта:

  var jQueryVersion = '1.11.2'; 
      var callback=function(isExists){ 
        if (isExists) { 
         window.myJquery= jQuery.noConflict(true); 

        } else {      
         window.myJquery= $ 
        } 
        console.log('local jQuery is loaded. Version: '.concat(window.myJquery.fn.jquery)); 
} 
      jQueryCheck: function(callback) { 

       var isExists = true; 
       if (!window.jQuery || !$) { 
        isExists = false; 
        console.log('no jQuery on the site. Injecting JQUERY version: ' + jQueryVersion); 
       } 
       if (!isExists || window.jQuery().jquery !== jQueryVersion) { 

        var jQueryInstance = document.createElement('script'); 

        jQueryInstance.type = 'text/javascript'; 
        jQueryInstance.src = url_to_you_jquery_library 
        jQueryInstance.onload = function() { 
         callback(isExists); 
        }; 
        jQueryGuavaInstance.onreadystatechange = function() { 
         if (this.readyState === 'complete') { 
          callback(isExists); 
         } 
        }; 
        document.getElementsByTagName('head')[0].appendChild(jQueryInstance); 
        if (isExists) { 
         concole.log('jQuery exists on the site. Version: '.concat(window.jQuery().jquery)); 
        } 

       } else { 
        console.log('current site version is equals to newest jquery version. Site version: ' + window.jQuery().jquery + ', Latest JQUERY version: ' + jQueryVersion); 
       } 

      }, 
Смежные вопросы