When passing in a data object, that contains 'url', to the ajax method it extends the params object with the data.
The issue is when 'data' includes a success callback function. The params passed to $.ajax internally include this success function, yet later the success function also gets called in the ok() method, which is called by the done() method.
So the result is my success function firing twice whenever I call eModal.ajax()
It also looks like the error() method suffers the same issue as well, though I was only troubleshooting the success issue
Below is the pertinent code I'm referring to in the ajax method:
if (data.url) {
$.extend(params, data);
}
$.ajax(params)
.done(ok)
.fail(error);
return alert(params, title);
function ok(html) {
$modal
.find('.' + MODAL_BODY)
.html(data.success ? data.success(html) : html);
When passing in a data object, that contains 'url', to the ajax method it extends the params object with the data.
The issue is when 'data' includes a success callback function. The params passed to
$.ajaxinternally include this success function, yet later the success function also gets called in theok()method, which is called by thedone()method.So the result is my success function firing twice whenever I call
eModal.ajax()It also looks like the
error()method suffers the same issue as well, though I was only troubleshooting thesuccessissueBelow is the pertinent code I'm referring to in the ajax method: