I'm having some issues getting the following code to work correctly:
(function($) {
'use strict';
Drupal.behaviors.mybehavior = {
attach: function(context, settings) {
$(document).once('abc').on('click', '.image_class', function() {
var fid = 123
var vid = 456
Drupal.ajax({
url: '/load/a/form/' + fid
}).execute().done(function() {
var id =
MktoForms2.loadForm('cname', '123-123-123', fid, function(form) {
form.onSuccess(function(e) {
form.getFormElem().hide();
Drupal.ajax({
url: '/load/a/video/' + vid
}).execute().done(function() {
});
return false;
});
});
})
});
}
}
})(jQuery);
The whole process works correctly but it duplicates previous AJAX calls at each step.
For instance, when I click the initial selector .image_class
the AJAX call that loads a form works great.
Once I complete the form successfully, the second AJAX call fires but this seems to also trigger the first AJAX call again effectively putting the form that was just completed and removed back on the page, re-opening the dialog.
Everything's triggering correctly, I just can't figure out how to get this process to work without re-triggering all the previous AJAX calls.
Thanks!