I have created a custom jquery widget in my magento 2 module. created widget is working fine but when this widget comes into action then my minicart stops open/close.

Here is my requirejs-config.js file content in app/code/vendor/module/view/frontend

**var config = {
  map: {
    '*': {
        queue: 'Lof_CustomerMembership/js/queue',
    }
  },
  shim: {
    queue: {
        deps: ['jquery','jquery/ui','underscore']
    }
  }
};**

queue.js :

define([
    'jquery',
    'underscore',
    'jquery/ui'
], function($, _){
    "use strict";
    $.widget("lof.queue", {
        options:{
            addToQueueSelector : "[data-role='add-to-queue'] button",
            removeFormSelector : "[data-role='remove-from-queue']",
            removeElementSelector : "[data-role='remove-from-queue'] i.remove",
        },
        _create: function(){
            console.log("hello");
        },
    });
    return $.lof.queue;
});

and in template I am calling this as:

<script type="text/x-magento-init">
{
    "form[data-role='remove-from-queue'] i":{
        "queue":{
            "action":"remove"
        }
    }
}
</script>

Please help me what I am doing wrong in creating this widget.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.