如何重置正在进行的切换?
以下是我正在使用的代码,在最后的评论中,我已经定义了我需要的内容。
(function($) {
$.fn.clickToggle = function(func1, func2) {
var funcs = [func1, func2];
this.data('toggleclicked', 0);
this.click(function() {
var data = $(this).data();
var tc = data.toggleclicked;
$.proxy(funcs[tc], this)();
data.toggleclicked = (tc + 1) % 2;
});
return this;
};
}(jQuery));
function showTakeNotes() {
// some functions will here while SHOWING the notes
}
function hideTakeNotes() {
// some functions will here while HIDING the notes
}
// Capturing the toggleClick event of '.btn-show-hide-take-slide-note'
$('.btn-show-hide-notes').clickToggle(function() {
showTakeNotes();
}, function() {
hideTakeNotes();
});
// there is another close button within the Notes widow to close the window
$(".btn-close-take-notes").clickToggle(function() {
hideTakeNotes();
}, function() {
// HERE I LIKE TO RUN RESET EVENT THAT'S ALREADY RECORDED WHILE SHOWING THE NOTES WINDOW .btn-show-hide-notes
});
答案 0 :(得分:1)
由toggleclicked
数据控制的功能。如果要重置它以调用showTakeNotes
功能。你可以用
$('.btn-show-hide-notes').data('toggleclicked', 0);