0

I'm trying to create a popup using the Fancybox plugin I'll explain the components:

  • Delivery details form in a separate element with an id of #deliverydetails
  • Checkbox with an id of sameAsCheckbox

Now I want the deliverydetails form to popup in a fancybox iFrame when the checkbox is unchecked. Any help would be appreciated!

$(function () {
    $("#sameAsCheckbox").click(function () {
        if ($(this).is(':unchecked')) $('#deliverydetails').fancybox('');
    });
});

Thanks!

rapture89
  • 125
  • 6
  • 17

2 Answers2

0

try

$("#sameAsCheckbox").click(function () {
    if ($(this).attr('checked') != 'checked') $('#deliverydetails').fancybox('');
});
0

Try this

$("#sameAsCheckbox").click(function () {
 if ($(this).is(':checked')) {
  $('#deliverydetails').fancybox('');
 } 
})

jFiddle Example

or you can also use this inside che click handler:

 if(this.checked) {
    //Do stuff
}

as discussed here

Community
  • 1
  • 1
Magico
  • 2,814
  • 1
  • 16
  • 17
  • Thanks for the fast replies which helped me get to the solution! $("#sameAsCheckbox").fancybox({ 'type': 'inline', 'href': '#delivery_details', 'titleShow': true, 'transitionIn': 'elastic', 'transitionOut': 'elastic' }); – rapture89 Apr 19 '13 at 10:21