I decided to modify and style i little bit my code with Alertify. My old code :
<script type="text/javascript">
$('.ask').click(function(){
var answer = confirm('<?php echo $this->translate('Delete route?'); ?>');
return answer;
});
When I press ok a php script runs and deletes the record. Javascript return true or false.
The problem I have with Alertify is that I even cant press ok or cancel, my php script runs before that. Here is the code:
$(".ask").click(function(event){
alertify.confirm("Are you sure you want to commit your reservation?", function (e) {
if (e) {
return true;
} else {
return false;
}
});
});
I saw some people with similar problems and I saw that I need to use prevent defaults (it makes sense) The code:
$(".ask").click(function(event){
event.preventDefault(); // cancel submit
alertify.confirm("Are you sure you want to commit your reservation?", function (e) {
if (e) {
return true; // submit form skipping jQuery bound handler
} else {
}
});
});
In that case the php script doesnt run before i press ok/cancel but it doesnt run too when i press one of the buttons. Nothing happens. Any help please ?