vojtech-dobes / nette.ajax.js

Flexible AJAX for Nette Framework. Supports snippets, redirects etc.
https://componette.org/vojtech-dobes/nette.ajax.js/
MIT License
149 stars 85 forks source link

Multiple $.nette.ajax() are cancelled #142

Closed zraly closed 7 years ago

zraly commented 7 years ago

As you can see on http://codepen.io/anon/pen/MpJNqz, if I call $.nette.ajax() more than once, only last call is successful. All previous ones are cancelled. Am I doing something wrong or is it a bug?

uestla commented 7 years ago

@medhi It's actually the 'unique' extension which is turned on by default.

https://github.com/vojtech-dobes/nette.ajax.js/blob/master/nette.ajax.js#L512-L523

But you can disable it - $.nette.ext('unique', null).

zraly commented 7 years ago

Oh, thanks! What is the unique extension for?

uestla commented 7 years ago

As I understand it it's when you click on a button but change your mind and click on another one before the previous request completes...

vojtech-dobes commented 7 years ago

If you find this behavior useful and want to disable it only for certain calls/elements, it's also possible:

$.nette.ajax({
    url: ...,
    off: ['unique']
});
<a href="..." data-ajax-off="unique"></a>

You can put this data attribute on any ajaxified element (form, button...).

zraly commented 7 years ago

@vojtech-dobes That's the best, thanks!