I have problem to run function after another completes. I try callback like in this post but this dont work Execute jquery function after another function completes so maybe i do something wrong or my case is more complicated.
So I have function that run when I submit the form
$("#search-form").submit(ajaxSubmit(addSearchfuntion)); // addSearchfuntion is callback
function ajaxSubmit(callback) {
var $form = $(this);
var settings = {
data: $(this).serialize(),
url: $(this).attr("action"),
type: $(this).attr("method")
};
$.ajax(settings).done(function(result) {
var $targetElement = $($form.data("ajax-target"));
var $newContent = $(result);
$($targetElement).replaceWith($newContent);
$newContent.effect("slide");
});
callback();
return false;
};
After this when I get new form to my page i want to run another function that will handle this new form.
function addSearchfuntion(){
$('.Amount').change(updateQuantity);
}
So how to solve this case?