Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define(
- [
- 'jquery',
- 'uiComponent',
- 'Magento_Customer/js/customer-data'
- ],
- function (jQuery, Component, customerData) {
- 'use strict';
- jQuery(document).on('click', '.tocart', function (e, config) {
- let idForm = "#form-"+jQuery(this).attr('rel');
- let form = idForm;
- var sections = ['cart'];
- let formData = jQuery(idForm).serialize();
- let button = idForm+" button";
- jQuery(button).html("<span>Adicionando...</span>");
- jQuery.ajax({
- url: jQuery(form).attr('action'),
- data: formData,
- type: 'GET',
- //url: "tableticket/category/addproducts",
- //type: 'POST',
- beforeSend: function() {
- // show some loading icon
- console.log('beforeSend');
- jQuery('body').trigger('processStart');
- },
- success: function(data, status, xhr) {
- // data contains your controller response
- customerData.invalidate(sections);
- customerData.reload(sections, true);
- console.log('success');
- jQuery(button).removeClass("bg_azul_light");
- jQuery(button).addClass('bg_salmao');
- jQuery(button).html("<span><i class=\"fa fa-pencil-square-o size18\"></i>Alterar Quantdade</span>");
- jQuery('body').trigger('processStop');
- },
- error: function (xhr, status, errorThrown) {
- console.log('Error happens. Try again.');
- console.log(errorThrown);
- jQuery('div.products-grid').trigger('processStop');
- }
- });
- });
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement