vitmalina / w2ui

UI widgets for modern apps. Data table, forms, toolbars, sidebar, tabs, tooltips, popups. All under 120kb (gzipped).
http://w2ui.com
MIT License
2.67k stars 727 forks source link

using w2ui with magento 2 #1335

Closed dalmatele closed 8 years ago

dalmatele commented 8 years ago

Okey. It takes me 2 days to fix this problem. Now I want to share with you. I have a problem that need to use w2ui (what a great plugin) in magento2, but w2ui does not compatible with RequireJS. So I can not use it. How to fix that? Okey, here is solution: I add my modified w2ui library on here (please keep in mind that only using it in magento 2 and with RequireJS) And in requirejs-config.js we add this:

var config = {
    map:{
        '*': {
           // configuration for resource 'app/code/Magento/Catalog/view/frontend/product/product.js'
           w2ui: "dalmate_CustomizeProductModule/js/w2ui/w2ui.min",
       }
    },
    shim: {
        'w2ui':{
            deps: ['jquery'],
            exports: 'w2ui'
        },
        'ui_widget': ['jquery'],
        'jquery':{
            exports: '$'
        }
    }
};

Then in template file we use it like this:

<script type="text/javascript">
       require(['jquery',
        'w2ui',
        'requirejs/domReady'],function($,w2ui){
                      'use strict';
                     domReady(function ($) {
                                var $ = jQuery.noConflict();
                                ///we call w2ui and jquery like normal
                     })
        })
</script>

[Uploading w2ui.min.zip…]()

mrg2001 commented 8 years ago

I am glad you found a solution and I hope it will be useful for people. Since it is not a bug, I am closing the issue.