Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences with jQuery 1.4.2 and 1.7.1?

Tags:

jquery

I build my site on jQuery version 1.4.2 (not realizing about any updates) but now it doesn't seem to work in IE8. When searching for a solution i thought about an update. When i use jQuery 1.7.1. however, some strange things occur. For example this example on jsFiddle

http://jsfiddle.net/64d2T/

When running this example in 1.4.4 it works fine, but when i run the code in 1.7.1 the format is messed up.

Does anybody know this problem and i'm a doing some basic stuff wrong?

like image 717
Maurice Avatar asked Dec 27 '22 09:12

Maurice


2 Answers

It depends from project to projects, what should you do when upgrading jQuery:

  1. isNumeric() is new, be careful as the older version jQuery.isNaN() has been deprecated
  2. jqXHR success and error have been deprecated
  3. When rendering content with text(), white space issue cross-browsers.
  4. attr() and prop() method are not the same and may cause troubles when you use attr() and than set values lets say for :
    $("input).attr("checked") 
    which priour to 1.6 returned true, now you should use
    $("input:checked")
  5. In 1.5 Ajax API was rewritten

Also it's a good idea to go through all release notes and understand the purpose of any change, and make some notes on what should you check in your project http://docs.jquery.com/Downloading_jQuery#Past_Releases

like image 191
Jackie Chan Avatar answered Jan 12 '23 08:01

Jackie Chan


the .add() method seems to be working differently ... providing a context fixes the problem :

http://jsfiddle.net/64d2T/5/

Replacing :

$(this).find('.news-title-description').add('.news-meta').add('.news-item-link').add('.news-header').addClass('active-news-item');

with :

$(this).find('.news-title-description').add('.news-meta',$(this)).add('.news-item-link',$(this)).add('.news-header',$(this)).addClass('active-news-item');
like image 24
Manse Avatar answered Jan 12 '23 08:01

Manse