Can't determine if cancel button have been click in a prompt box
rconcil opened this issue · 3 comments
rconcil commented
Following this example http://jsfiddle.net/8vdvo13m/10/
I'm enable to determine if the cancel button have been clicked.
Usually null is returned when you click cancel in a prompt but here the text in the input is returned.
thecodeholic commented
Every messagebox has callback
option which is called when button is clicked. It takes 3 parameters:
- Lobibox instance
- button key
- event
If you listen to this callback you will know which button is clicked.
Lobibox.prompt('text',
{
title: 'Test de prompt',
attrs: {
placeholder: 'Placeholder text'
},
beforeClose: function (lbb) {
if(lbb.getValue().length > 0) {
alert('We have something');
} else {
alert('We have nothing');
}
},
callback: function(box, btn){
//btn will be ok or cancel depending which button you clicked
console.log(box, btn);
}
});
rconcil commented
The callback function resolved my problem.
Thanks a lot for your explanation!
thecodeholic commented
You are welcome. For any question fell free to contact.