Javascript/Jquery Callback for Fancybox Yes No Confirm

前端 未结 2 1923
南笙
南笙 2021-01-06 19:12

I\'m trying to implement a fancy Yes No confirm and I\'m having problems getting the callback to work as needed. The example below is using Fancybox v2.

The problem

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 19:31

    Your method "do_something('a', 'b')" will be executed whenever user clicks on the link and the returned result will be passed as the second parameter to the "fancyConfirm" method. This is why your parameter "callback" is always "undefined".

    There is also a problem with fancyBox - "afterClose" callback gets called twice - before opening and after closing (this will be changed in the next release).

    I would bind a click event on the link and call a callback when user clicks on one of the buttons, like - http://jsfiddle.net/xcJFY/1/

提交回复
热议问题