Reputation: 16513
How can I reset ongoing toggle?
Below is the code that I am using and at very last comment I have defined what I need.
(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
});
Upvotes: 0
Views: 1620
Reputation: 133403
Which function to be controlled by toggleclicked
data. If you want to reset it to call showTakeNotes
function. you can use
$('.btn-show-hide-notes').data('toggleclicked', 0);
Upvotes: 1