1

i'm trying to plugin custom action to fancy close button, but nothing is happening, why is that ??

my code

$(".fancybox-close").click(function(){
    $("#main-menu-nav a").removeClass("active");
    $("footer").toggleClass("down", 400);
});
4

3 に答える 3

4

Fancybox has a callback onClose you can define in its parameters

please try to use:

$("#TARGET_ELEMENT").fancybox({
 'OTHER_PARAM':'OTHER_PARAM_VALUE',
 'onClosed': function() {
   alert("FIRED_ON_CLOSE");
  }
 });

Happy coding!

于 2012-07-12T08:40:51.547 に答える
1

$("footer").toggleClass("down", 400); is invalid jQuery code, toggleClass's second parameter must be a boolean http://api.jquery.com/toggleClass/.

于 2012-07-12T08:41:35.597 に答える
1

Fancybox v1 provides API with a onClosed method that's called when Fancybox closes.
Fancybox v2 provides API with a afterClose method that's called when Fancybox closes.

The Tips & Tricks page has the method to use this public callback as seen below:

$("#tip5").fancybox({
    'scrolling'     : 'no',
    'titleShow'     : false,
    'afterClose'        : function() {
       $("#main-menu-nav a").removeClass("active");
       $("footer").toggleClass("down", 400);
    }
});

Using this method to call your custom actions will ensure they are invoked when the overlay is clicked to close Fancybox, since the button itself isn't clicked.

Status Update: Per Simon's Answer on this page, note his point that you may have an issue with the switch parameter for the .toggleClass(); method since the value of 400 may not do what your expecting unless (as the comment states), your using jQuery UI.

于 2012-07-12T08:43:22.550 に答える