Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /**
  2. * On submitting the form the OffCanvas shall open, the product has to be posted
  3. * against the storefront api and after that the current cart template needs to
  4. * be fetched and shown inside the OffCanvas
  5. * @param {Event} e
  6. * @private
  7. */
  8. _onFormSubmit(e) {
  9. e.preventDefault();
  10.  
  11. const form = e.target;
  12. const requestUrl = DomAccess.getAttribute(form, 'action');
  13.  
  14. // Open the OffCanvas first
  15. OffCanvas.open(LoadingIndicator.getTemplate(), () => {
  16. // Fire POST request for adding the product to cart
  17. this.client.post(requestUrl.toLowerCase(), this._convertFormDataToJSON(new FormData(form)), () => {
  18. // Update the CartWidget in the header
  19. CartWidget.fetch();
  20. // Fetch the current cart template and replace the OffCanvas content
  21. this.client.get(window.router["frontend.cart.detail"], (response) => {
  22. OffCanvas.setContent(response);
  23. this._registerRemoveProductTriggerEvents();
  24. });
  25. });
  26. }, CART_MINI_POSITION);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement