2013-12-19 3 views
0

Итак, в основном весь сайт работает с jQuery версии 1.9.1. Хотя, я бы хотел использовать плагин, который использует только версию 1.4.1. Есть ли что-то маленькое, которое должно быть изменено в этом коде плагина, чтобы он был совместим с 1.9.1?Почему мой jQuery не работает с версией 1.9.1?

Я пробовал несколько вещей, таких как преобразование его в обычный Javascript (не повезло) и попытка загрузить версию 1.4.1 aswel .. хотя это только заставило многие другие вещи на моем сайте не работать.

$(document).ready(function() { 

     // Get all the thumbnail 
     $('div.thumbnail-item').mouseenter(function(e) { 

      // Calculate the position of the image tooltip 
      x = e.pageX - $(this).offset().left; 
      y = e.pageY - $(this).offset().top; 

      // Set the z-index of the current item, 
      // make sure it's greater than the rest of thumbnail items 
      // Set the position and display the image tooltip 
      $(this).css('z-index','15') 
      .children("div.tooltip") 
      .css({'top': y + 10,'left': x + 20,'display':'block'}); 

     }).mousemove(function(e) { 

      // Calculate the position of the image tooltip   
      x = e.pageX - $(this).offset().left; 
      y = e.pageY - $(this).offset().top; 

      // This line causes the tooltip will follow the mouse pointer 
      $(this).children("div.tooltip").css({'top': y + 10,'left': x + 20}); 

     }).mouseleave(function() { 

      // Reset the z-index and hide the image tooltip 
      $(this).css('z-index','1') 
      .children("div.tooltip") 
      .animate({"opacity": "hide"}, "fast"); 
     }); 

    }); 

Эти ошибки я ПОЛУЧАТЬ:

Failed to load resource: the server responded with a status of 404 (Not Found) http://jqueryui.com/slider/jquery-ui.js 
Uncaught ReferenceError: jq141 is not defined (index):574 
2999 (index):660 
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.ozcaravan-sales.com.au/wp-content/themes/listings/style/images/ui-bg_glass_75_e6e6e6_1x400.png 
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.ozcaravan-sales.com.au/wp-content/themes/listings/style/images/ui-bg_flat_75_ffffff_40x100.png 
Failed to load resource: the server responded with a status of 404 (Not Found) http://www.ozcaravan-sales.com.au/wp-content/themes/listings/style/images/ui-bg_highlight-soft_75_cccccc_1x100.png 
Failed to load resource: the server responded with a status of 404 (Not Found) http://dev.wizie.com/team/http://mangocell/favicon.ico 
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. 
+0

Вы получаете ошибки? – j08691

+0

У нас есть jsfiddle.net? – underscore

+0

@ j08691 - Мне удалось немного исправить это, объявив версию 1.9.1 непосредственно перед кодом плагинов. Хотя, это вызывает большие нарушения в других вещах на моем сайте ... Любые предложения? Это потому, что я объявляю это дважды? – Fizzix

ответ

0

Итак, после исследования я просто попробовал этот плагин в 1.9.1, и он работал отлично. У меня не было никаких ошибок. Я не думаю, что 1.9.1 это ваша проблема, если ваш пример не работает.
http://jsfiddle.net/NLw5F/

Это плагин, работающий в jQuery 1.9.1.

$(document).ready(function() { 

    // Get all the thumbnail 
    $('div.thumbnail-item').mouseenter(function(e) { 

     // Calculate the position of the image tooltip 
     x = e.pageX - $(this).offset().left; 
     y = e.pageY - $(this).offset().top; 

     // Set the z-index of the current item, 
     // make sure it's greater than the rest of thumbnail items 
     // Set the position and display the image tooltip 
     $(this).css('z-index','15') 
     .children("div.tooltip") 
     .css({'top': y + 10,'left': x + 20,'display':'block'}); 

    }).mousemove(function(e) { 

     // Calculate the position of the image tooltip   
     x = e.pageX - $(this).offset().left; 
     y = e.pageY - $(this).offset().top; 

     // This line causes the tooltip will follow the mouse pointer 
     $(this).children("div.tooltip").css({'top': y + 10,'left': x + 20}); 

    }).mouseleave(function() { 

     // Reset the z-index and hide the image tooltip 
     $(this).css('z-index','1') 
     .children("div.tooltip") 
     .animate({"opacity": "hide"}, "fast"); 
    }); 

}); 

Прямо от демо.

+0

Как я упоминал ранее, он, похоже, работает над версией 1.9.1 после дальнейших испытаний. Хотя, я обнаружил, что мой сайт использует 1.10.2, а не 1.9.1. Поэтому плагин не работает с 1.10.2 – Fizzix

+0

Мой пример также работает с 1.10.2: http://jsfiddle.net/NLw5F/1/ – Johnston

0

С каждой версией JQuery некоторые из методов API устарели и удалены и некоторые другие добавляют. Я думаю, ваш плагин пытается получить доступ к некоторым из этих удаленных методов из ядра jQuery. Для решения вы можете либо найти новую версию плагина, если он поддерживается, либо найти новый плагин с одинаковыми фетами. Вы также можете использовать плагин jQuery migrate, но он поддерживает его только с версии, равной или большей, чем jQuery 1.6.4. Дополнительная информация here

+0

Поэтому я могу просто указать '' после загрузки jQuery? – Fizzix

+0

да, я предоставил ссылку выше. –

+0

Это, к сожалению, не решило мою проблему. – Fizzix

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