Skip to content

Pass arguments to AJAX_SUCCESS and AJAX_FAIL #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -225,7 +225,7 @@ The following events are triggered when AJAX modals are requested.
$.modal.AJAX_FAIL = 'modal:ajax:fail';
$.modal.AJAX_COMPLETE = 'modal:ajax:complete';

The handlers receive no arguments. The events are triggered on the `<a>` element which initiated the AJAX modal.
The handlers receive the same arguments as the jQuery `jqXHR.done()` and `jqXHR.fail()` promise methods. The events are triggered on the `<a>` element which initiated the AJAX modal.

## More advanced AJAX handling

4 changes: 2 additions & 2 deletions jquery.modal.js
Original file line number Diff line number Diff line change
@@ -28,13 +28,13 @@
el.trigger($.modal.AJAX_SEND);
$.get(target).done(function(html) {
if (!current) return;
el.trigger($.modal.AJAX_SUCCESS);
el.trigger($.modal.AJAX_SUCCESS,arguments);
current.$elm.empty().append(html).on($.modal.CLOSE, remove);
current.hideSpinner();
current.open();
el.trigger($.modal.AJAX_COMPLETE);
}).fail(function() {
el.trigger($.modal.AJAX_FAIL);
el.trigger($.modal.AJAX_FAIL,arguments);
current.hideSpinner();
el.trigger($.modal.AJAX_COMPLETE);
});