1 Comment

Magento 2 does not read my requirejs-config.js

Magento 2 Inline translate for script strings
Magento duplicate the product getting innodb lock timeout error

I’m customizing customer address tab in Admin Panel. Here is my code. It’s reading my files but ‘Add New Addresses’ button is not responding.

my code is:

app/code/Learning/Helloworld/view/adminhtml/requirejs-config.js

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

var config = {
    map: {
        '*': {
            'Magento_Ui/js/form/components/collection':'Learning_Helloworld/js/form/components/collection'
        }
    }
};

app/code/Learning/Helloworld/view/adminhtml/web/js/form/components/collection.js

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
define([
    'underscore',
    'mageUtils',
    'uiRegistry',
    'uiComponent',
    'uiLayout',
    'Magento_Ui/js/modal/confirm'
], function (_, utils, registry, Component, layout, confirm) {
    'use strict';

    var childTemplate = {
        parent: '${ $.$data.name }',
        name: '${ $.$data.childIndex }',
        dataScope: '${ $.name }',
        nodeTemplate: '${ $.$data.name }.${ $.$data.itemTemplate }'
    };

    return Component.extend({
        defaults: {
            lastIndex: 0,
            template: 'Learning_Helloworld/form/components/collection'
        },
..........................
    });
});

app/code/Learning/Helloworld/view/adminhtml/web/template/form/components/collection.html

<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<div class="ui-tabs">
    <ul class="address-list ui-tabs-nav">
        <h1>Magento 2</h1>
        <!-- ko foreach: { data: element.elems, as: 'element' } -->
        <li class="address-list-item" data-bind="css: { 'ui-state-active': element.active }, click: activate">
            <div class="address-list-item-actions">
                <button class="action-delete" type="button" data-bind="click: $parent.removeAddress.bind($parent, element)">
                    <span data-bind="text: $parent.removeLabel"></span>
                </button>
            </div>
            <!-- ko template: previewTpl --><!-- /ko -->
            <div data-bind="foreach: { data:  element.getRegion('head'), as: 'element' }">
                <!-- ko template: element.getTemplate() --><!-- /ko -->
            </div>
        </li>
        <!-- /ko -->

        <li class="address-list-actions last">
            <button data-bind="click: element.addChild" type="button" class="scalable add">
                <span data-bind="text: element.addLabel"></span>
            </button>
        </li>
    </ul>
    <!-- ko foreach: { data: element.elems, as: 'element' } -->
    <div class="address-item-edit" data-bind="visible: element.active">
        <div class="address-item-edit-content">
            <fieldset class="admin__fieldset">
                <legend class="admin__legend">
                    <span data-bind="text: $parent.label"></span>
                </legend>
                <br>
                <!-- ko foreach: { data: element.getRegion('body'), as: 'element' } -->
                <!-- ko template: element.getTemplate() --><!-- /ko -->
                <!-- /ko -->
            </fieldset>
        </div>
    </div>
    <!-- /ko -->
</div>

After I have ran below commands

php bin/magento cache:clean

php bin/magento cache:flush

php bin/magento setup:static-content:deploy

‘Add New Addresses’ button is not responding in ‘Addresses’ tab. Where went wrong?

Related Posts

  • Magento2 Custom theme register but does read layout & template files (1)
    I have create a custom theme and it has been register but it does not read layout & Templates. File location: app/design/frontend/Amit/Customtheme/composer.json { "name": "magento/theme-frontend-Customtheme", "description": "N/A", "require": { "php": […]
  • Cannot read contents from file appdesignadminhtmlMagentobackendetcmodule.xml in Magento 2 (1)
    I have created a adminhtml theme but it's throwing error. Could you please clarify me where I went wrong? my code is: root/app/design/adminhtml/Magento/backend/composer.json { "name": "magento/theme-adminhtml-backend", "description": "N/A", "require": { "php": […]
  • Can't amend form.phtml as part of contact module magento 2 (0)
    I'm trying to change copy in the form.phtml (Magento_Contact module) but whenever I upload the file to my theme, all I get back is this: I've uploaded it to: app/design/frontend/{vendor}/{theme}/Magento_Contact/templates/form.phtml along with the layout files (/layout) The code […]
  • Magento 2: Creating a custom layout (1)
    I'm having trouble creating a custom layout. I have successfully created a layout called home_page.xml which is a copy of the default 1column layout. I have selected this layout for my home page, but can't seem to add any content to it. Am I limited to only adding containers to the […]
  • Script doesn't Reflect frontend (1)
    I added script file to view/templates/chat.phtml its not reflect for me, This is My Layout File view/frontend/layout/default.xml <?xml version="1.0"?> <!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page […]
  • How to make the fields of the fieldset multidependable? (5)
    I have a fieldset in the admin panel with one parent select (has 5 options) and 2 fields, which should be displayed in case the parent value select will be 3, 4 or 5. I have not found the examples of similar logic in magento and tried to write by analogy with the usual dependence, […]
  • How to remove html head body tags in layout magento 2 (1)
    Controller <?php namespace TestQuickViewControllerCatalogProduct; class View extends MagentoCatalogControllerProductView { } Layout quickview_catalog_product_view.xml <?xml version="1.0"?> <!-- /** * Copyright © 2016 Magento. All rights reserved. * See […]
  • Magento 2 custom module gives list page blank (1)
    I have custom module the news_index_index file is as bellow. <?xml version="1.0"?> <!-- /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ --> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" […]
  • Create Employee Module like Customer module in magento 2 (2)
    I have created Employee module. same as customer module. i have copied all files from vendor/magento/module-customer to app/code/Magento/Employee. I replaced customer with employee. but it shows an error: 'InvalidArgumentException' with message 'Constant name is expected. and […]
  • how to extend/inject this to customer address in magento 2 (3)
    I'm trying to extend customer address page, but it's overriding. I want to inject in the middle of the address tab form. My Code is: Learning/CustomerAddress/composer.json { "name": "learning/CustomerAddress", "description": "Customer Address", "require": { […]
Magento 2 Inline translate for script strings
Magento duplicate the product getting innodb lock timeout error

1 Comment on this article

  • User November 12, 2016

    try the below code

    app/code/Learning/Helloworld/view/base/requirejs-config.js

    /**
     * Copyright © 2015 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    
    var config = {
        map: {
            '*': {
                'Magento_Ui/js/form/components/collection':'Learning_Helloworld/js/form/components/collection'
            }
        }
    };
    

    app/code/Learning/Helloworld/view/base/web/js/form/components/collection.js

    /**
     * Copyright © 2015 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    define([
        'underscore',
        'mageUtils',
        'uiRegistry',
        'uiComponent',
        'uiLayout',
        'Magento_Ui/js/modal/confirm'
    ], function (_, utils, registry, Component, layout, confirm) {
        'use strict';
    
        var childTemplate = {
            parent: '${ $.$data.name }',
            name: '${ $.$data.childIndex }',
            dataScope: '${ $.name }',
            nodeTemplate: '${ $.$data.name }.${ $.$data.itemTemplate }'
        };
    
        return Component.extend({
            defaults: {
                lastIndex: 0,
                template: 'Learning_Helloworld/form/components/collection'
            },
    ..........................
        });
    });
    

    app/code/Learning/Helloworld/view/base/web/template/form/components/collection.html

    <!--
    /**
     * Copyright © 2015 Magento. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <div class="ui-tabs">
        <ul class="address-list ui-tabs-nav">
            <h1>Magento 2</h1>
            <!-- ko foreach: { data: element.elems, as: 'element' } -->
            <li class="address-list-item" data-bind="css: { 'ui-state-active': element.active }, click: activate">
                <div class="address-list-item-actions">
                    <button class="action-delete" type="button" data-bind="click: $parent.removeAddress.bind($parent, element)">
                        <span data-bind="text: $parent.removeLabel"></span>
                    </button>
                </div>
                <!-- ko template: previewTpl --><!-- /ko -->
                <div data-bind="foreach: { data:  element.getRegion('head'), as: 'element' }">
                    <!-- ko template: element.getTemplate() --><!-- /ko -->
                </div>
            </li>
            <!-- /ko -->
    
            <li class="address-list-actions last">
                <button data-bind="click: element.addChild" type="button" class="scalable add">
                    <span data-bind="text: element.addLabel"></span>
                </button>
            </li>
        </ul>
        <!-- ko foreach: { data: element.elems, as: 'element' } -->
        <div class="address-item-edit" data-bind="visible: element.active">
            <div class="address-item-edit-content">
                <fieldset class="admin__fieldset">
                    <legend class="admin__legend">
                        <span data-bind="text: $parent.label"></span>
                    </legend>
                    <br>
                    <!-- ko foreach: { data: element.getRegion('body'), as: 'element' } -->
                    <!-- ko template: element.getTemplate() --><!-- /ko -->
                    <!-- /ko -->
                </fieldset>
            </div>
        </div>
        <!-- /ko -->
    </div>
    

    after that execute the below commands in CLI

    php bin/magento cache:clean
    
    php bin/magento cache:flush
    
    php bin/magento setup:static-content:deploy
    

    Please let me know if it is not working.

    happy coding!!!!!!.

    Reply

Add a comment

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax