Releases: naja-js/naja
1.8.0
SnippetHandlerevents now have thefromCacheflag. ThebeforeUpdateandafterUpdateevents now carry the information about whether the snippet is being updated from cache after user navigation (i.e. going back in history), or as a result of an AJAX request to the server.RedirectHandlerdetects local redirects viaUIHandler.allowedOrigins. Until now, redirects leading to the same origin were done via another AJAX request (unless forced otherwise). This detection now takes into account the configured allowed origins, which means that redirects to any of the allowed origins is processed asynchronously by default.RedirectHandlerdispatches theredirectevent prior to redirection. This event allows you to override the soft vs. hard redirection settings, or even entirely prevent the redirection from happening.
2.0.0-alpha1
2.0.0-alpha.1
1.7.0
-
Deprecate reading options from response payload (#44). After some thought, I consider passing options such as
replaceHistoryorforceRedirectto Naja via the response payload to be a cul-de-sac; server should not be able to affect the client-side processing of the request in such direct way. Therefore, Naja now emits a deprecation warning if it encounters such options in the payload, and will stop supporting them in 2.0. -
RedirectHandler: pass original options to the new "redirection" request (#45). If the target redirection URL is local (i.e. relative, or absolute pointing to the same origin), RedirectHandler sends another AJAX request instead of redirecting. Since redirect sequences are usually perceived as a single request, Naja now mimics such flow by passing the
optionsof the original request to the redirected request, so that the intended behaviour of the request is preserved.
1.6.0
-
Refactor UIHandler and FormsHandler to only rebind updated snippets (#19). This is a simple internal refactoring which could lead to a better performance. As a side effect, the
UIHandlernow exposes thebindUI()method which you can use to manually bind the AJAX handler to DOM nodes that are created dynamically via a different mechanism than Nette snippets. -
Accept defaultOptions in naja.initialize() (#24). The
naja.initialize()method now acceptsdefaultOptions, adding a second way to configure them in addition to modyfingnaja.defaultOptionsdirectly. The default options passed to the initialize method are also provided to theinitevent listeners. -
HistoryHandler: implement disabling UI cache (#17). This is an advanced feature that entirely disables the UI state cache; this helps prevent errors caused by big snippets that exceed the maximum storage quota. During navigation through the browser history, requests are actually sent again rather than artificially replayed from the history entry state. Be sure that you know what you're doing before using this feature.
-
Optimized SnippetHandler prepend/append (#20). Thanks @vitkutny!
1.5.1
1.5.0
1.4.0
- Added
UIHandler.clickElement()andUIHandler.submitForm()helper methods (#12) that allow you to dispatch UI-bound events manually. This is especially useful if you need to submit a form programmatically (e.g. on change of select box), becauseform.submit()does not trigger the form'ssubmitevent.⚠️ The helper methods trigger theinteractionevent withoriginalEventset to undefined. This potentially breaks BC if you choose to use the newly introduced methods!
- Simplified initial pop detection (#10). It doesn't appear to be a problem anymore, but in browsers where it still is a problem (some ancient Chromes and Safaris), this solution should work too while being elegantly simple. As a side effect, this should also prevent
popstatebehaviour in HistoryHandler being triggered onhashchange.⚠️ This also removes a few attributes from HistoryHandler that are no longer necessary:initialUrl,initialState, andpopped. They were part of the internal API and were never documented, thus I don't consider their removal to be a BC break.
1.3.2
1.3.1
1.3.0
- You can provide default options for your extensions or even Naja's core components via
naja.defaultOptions. - The
optionsobject is now passed to thesuccess,error, andcompleteevent handlers. Components and extensions can now use theoptionsobject to pass metadata along with the request instead of having to keep track of them internally, which should prevent potential concurrency issues. - RedirectHandler reads the
forceRedirectflag not only from response payload but also fromoptions.