Warning: mysqli_query(): (HY000/1021): Disk full (/tmp/#sql-a2c-1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device") in /var/www/html/wp-includes/wp-db.php on line 2024

Warning: mysqli_query(): (HY000/1021): Disk full (/tmp/#sql-a2c-1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device") in /var/www/html/wp-includes/wp-db.php on line 2024
class="post-442463 post type-post status-publish format-standard hentry" id="post-442463">

Define an even on select with event observer

My template is located in src/app/design/frontend/MySite/default/Magento_Checkout/templates/cart/item/default.phtml

There is a select and in this select I’m adding an event.

<select id="cart-<?= /* @escapeNotVerified */ $_item->getId() ?>-qty"
        name="cart[<?= /* @escapeNotVerified */ $_item->getId() ?>][qty]"
        data-cart-item-id="<?= $block->escapeHtml($_item->getSku()) ?>"
        title="<?= $block->escapeHtml(__('Quantity')) ?>"
        class="qty"
        data-role="cart-item-qty"
        data-bind="event:{ change: qtyChanged}">

Problem is when I load the page checkout/cart/ where the select id, I have this js error :

VM25008:3391 Uncaught ReferenceError: Unable to process binding “event: function(){return { change:qtyChanged} }”
Message: qtyChanged is not defined
at event (eval at createBindingsStringEvaluator (eval at req.exec (require.js:2063)), :3:74)
at init (eval at req.exec (require.js:2063), :4241:30)
at eval (eval at req.exec (require.js:2063), :3368:46)
at Object.ignore (eval at req.exec (require.js:2063), :1480:33)
at eval (eval at req.exec (require.js:2063), :3367:48)
at Object.arrayForEach (eval at req.exec (require.js:2063), :159:17)
at applyBindingsToNodeInternal (eval at req.exec (require.js:2063), :3353:22)
at applyBindingsToNodeAndDescendantsInternal (eval at req.exec (require.js:2063), :3233:37)
at applyBindingsToDescendantsInternal (eval at req.exec (require.js:2063), :3215:13)
at applyBindingsToNodeAndDescendantsInternal (eval at req.exec (require.js:2063), :3242:13)

And here is the place I write the new file

src/app/code/Cam/Checkout/view/frontend/web/js/view/cart/item/default.js

And that’s the content

define([
    'Cam_Checkout/cart/item/default'
], function (Form) {
    'use strict';

    return Form.extend({
        defaults: {
            template: 'Cam_Checkout/cart/item/default'
        },

        qtyChanged : function () {
            console.log("Qty changed called");
        }
    });
});

Leave a Reply

Your email address will not be published. Required fields are marked *