I have these two sets of codes, one of which should be displayed whenever a button is clicked,
$('.button_class').click(function(){
var baker_url = base_url + 'baker/baker/manage/Bread/1';
var answer = confirm('Are you sure?');
if(answer == true){
}
else if(answer == false){
return false;
}
});
and then this piece of code here is the one that is responsible for executing the process when the button is clicked,
$('.another_button_class').click(function(e){
e.preventDefault();
var baker_url = base_url + 'baker/baker/manage/Bread/1';
var form = '#'+ $(this).attr('rel');
var url = $(form).attr('action');
var target = '#'+ $(form).attr('rel');
$(target).slideUp();
$.post(url, $(form).serialize(),function(data) {
$(target).html(data).slideDown(function(){
if(data == '<div class="ok">Added</div>'){
setTimeout(refresh,1000)
c();
window.location = baker_url;
}
});
});
});
in the first function, when answer == true, I want to execute the last function (the one with which the process is executed when the button is pressed).
Is it possible that I can call another function or event handler to execute my process inside another function?
source
share