Add open and close callbacks
ssenior45 opened this issue · comments
Great widget, thanks very much for writing.
I think it would be useful for you to add an open and close callback in the init i.e.:
widget.js
if(args.openCallback) {
//add a callback function when this opens
$.popover.addEventListener('open', function(e){
e.bubbles = false;
e.cancelBubble = true;
args.openCallback();
});
}
if(args.closeCallback) {
//add a callback function when this closes
$.popover.addEventListener('close', function(e){
e.bubbles = false;
e.cancelBubble = true;
args.closeCallback();
});
}
So you get two more args when you init - e.g:
// initialize the popover
$.popover.init({
title: 'Title',
showLeftNavButton: true,
leftNavButtonTitle: 'Done',
leftNavCallback: function() {
// function run after left button is clicked
alert(JSON.stringify(rowClicked));
},
showRightNavButton: true,
rightNavButtonTitle: 'Next',
rightNavCallback: function() {
alert(JSON.stringify(rowClicked));
},
// set to true to disable tapping on backshade to close
disableBackshadeClose: false,
// view to show within the popover
//view: args.view
openCallback: function() {
alert('open callback');
},
closeCallback: function() {
alert('close callback');
}
});
Well, it took me long enough. But I've finally implemented this. Sorry for taking so long. Thanks for the suggestion.