0

I am using this jquery plugin for Apple like checkbox button.

However when I use jquery version 1.4.2 it works perfectly but when I try to use jquery version 1.6. that plugin doesn't work.

I tried debugging javascript using IE9 developer toolbar but it is not throwing any error.

Thank you.

Bharat Patil
  • 1,398
  • 1
  • 11
  • 28

2 Answers2

2

EDIT: got it working in FF4 as well now, see this: jQuery 1.6: backgroundPosition vs backgroundPositionX and FF4 compatibility

Got it working with jQuery 1.6.x and 1.5.x (in Safari and Chrome on Mac, not working in FF4/Mac)

There were two problems with the original code, one making it incompatible with jQuery 1.5 and 1.6 and one making it incompatible with jQuery 1.6.

The first problem was the use of the

backgroundPosition property 

in the animate calls, they needed to be changed into the

backgroundPositionX property

for jQuery 1.5 and 1.6

The second problem was the check for whether the checkbox is checked or not. In jQuery 1.4 and 1.5 this could be done with

if ( $(this).attr('checked') == true )

but in jQuery 1.6 this does not work, it need to be changed into

if ( $(this).is(':checked') )

The code found here works for jQuery 1.6: http://jsfiddle.net/mikkelbreum/HAGMp/

Community
  • 1
  • 1
mikkelbreum
  • 3,021
  • 9
  • 38
  • 41
  • Hey...That is nice...I tried it in firefox 4 it is not sliding thought checkbox's value is changing but in Safari it is working. – Bharat Patil Jun 12 '11 at 05:35
  • yes I found out as well it's not working in FF4, looking into that at the moment.. not sure what's happening there, firebug is giving wierd messages about 'attempt to run compiles script on closed scope' that I do not understand.. and also that it fails to load a resource.. – mikkelbreum Jun 12 '11 at 12:23
  • I updated the jsfiddle link, the server where the images was stores was no longer responding, so i changed to another server. – mikkelbreum Jun 12 '11 at 12:46
  • To make it work in FF4 change the animate lines to: animate({backgroundPosition: '0px'}) and animate({backgroundPosition: settings.switch_swing+'px'} see: jsfiddle.net/mikkelbreum/uHkE5 – mikkelbreum Jun 13 '11 at 19:35
0

Try updating to jQuery 1.6.1. With 1.6, they broke backwards compatibility with .attr() (which breaks many plugins) but the 1.6.1 update addresses this.

scurker
  • 4,733
  • 1
  • 26
  • 25
  • You should probably file a report with the developer then. There's a ticket open that is reporting issues with [jQuery > 1.4.2](http://code.google.com/p/icheckbox/issues/detail?id=4). – scurker May 17 '11 at 15:10
  • I have the same problem. the plugin code is fairly short.. if the developer does not have time to fix it, it should be an easy task for another developer. I'll have a look at it. – mikkelbreum Jun 09 '11 at 22:30
  • got it working in FF4, but in a wierd way, see edit note in my answer – mikkelbreum Jun 12 '11 at 14:02