Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is it feasible to attach a callback to the function and have that call back fire within the ajax done callback? Or do you actually need the ajax object itself other than to attach a done() listener to it</p> <pre><code>HandleModalFormSubmit: function (element, callBack) { var form, modalcontainer = $(element).closest('.modal'), modal = $(element).closest('.modal-dialog'), ajaxdata; if (element.is('form')) form = $(element); else { form = element.find('form'); } $.validator.unobtrusive.parse(form); $(element).on('submit', function (event) { event.preventDefault(); ajaxdata = $.ajax({ type: form.method, url: form.action, data: $(form).serialize() }).done(function (data) { if (data.status == null) { modal.html(data); } else { modalcontainer.modal('hide'); }; //call the callback within the done function of the ajax object here if(callBack &amp;&amp; typeof callBack == "function") callBack.call(context, params); }).always(function (data) { modal.spin(false); modal.fadeTo(500, 1); }); modal.fadeTo(300, 0); modal.spin(); }); var returningobject = { element: form, ajax: ajaxdata }; return returningobject; } } </code></pre> <p>Obviously this doesn't give you the ajax object itself back but you can plugin the callback and kick out whatever parameters you need.</p> <p>Edit: You could also return the jquery ajax function itself something like this :</p> <pre><code>HandleFormSubmit : function(){ return $.ajax({}); } </code></pre> <p>then you could attach your done method like so :</p> <pre><code>HandleFormSubmit().done(function(){ }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload