Skip to content
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

success callback fired twice in ajax method #91

Open
bretdavi opened this issue Jul 17, 2019 · 1 comment
Open

success callback fired twice in ajax method #91

bretdavi opened this issue Jul 17, 2019 · 1 comment

Comments

@bretdavi
Copy link

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);
@bretdavi
Copy link
Author

Any feedback here???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant