I am trying to write a function with multiple callback functions. Am I doing this right or is there a better way?
$('.question a').click(function(ev) {
$('.answers').load(url, function() {
$('#AnswerBox').addClass('mceEditor',
function() {tinyMCE.init({
theme : "advanced",
mode : "specific_textareas",
editor_selector : "AnswerBox",
elements: "AnswerBox",
plugins : "fullpage",
theme_advanced_buttons3_add : "fullpage",
});
})
})
return false;
});
I know you can do a 2-layer function in this way, but can you also do more?
Yes, you can nest more functions, but callback functions are used to know when asynchronous events are complete.Setting class doesn’t happen asynchronously, so you dont have any callback function in addClass. So it should be something like,