1

I tried to put # places of the url, but the url still works and e.stopImmediatePropagation () with js also didn't help. Is there any way to do this through xml or otherwise? Thanks

 <item name="buttons" xsi:type="array">
            <item name="alert_text" xsi:type="array">
                <item name="name" xsi:type="string">alert_text</item>
                <item name="label" xsi:type="string" translate="true">Custom Button</item>
                <item name="class" xsi:type="string">primary</item>
                <item name="url" xsi:type="string">*/*/url</item>
            </item>
        </item>

2 Answers 2

0

use this in a button

<item name="disabled" xsi:type="boolean">true</item>

Offical dev doc https://devdocs.magento.com/guides/v2.3/ui_comp_guide/components/ui-button.html

Ok, I got your concern. Try the below line. It adds a url but it does not work on click.

  <item name="url" xsi:type="string">'#'</item>
4
  • Padhiyar Gaurang, thanks for the answer, but this completely disable the button, I need it to be clickable simply without a link
    – Robinio
    Commented Dec 10, 2019 at 9:22
  • @RobinioTor i have updated an answer. please check. Commented Dec 11, 2019 at 6:20
  • Padhiyar Gaurang,with '#' give an error with # url works , i solved that like this jQuery('body').find('#button').removeAttr('onclick'); not a good option but so far only this has yielded result, thanks for you time
    – Robinio
    Commented Dec 11, 2019 at 8:37
  • @RobinioTor for better result use jQuery('body').find('button#alert_text').removeAttr('onclick'); Commented Dec 11, 2019 at 8:49
0

When using a block I was able to set url as null and that worked for me.

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class saveData implements ButtonProviderInterface
{
    /**
     * @return array
     */
    public function getButtonData()
    {
        return [
            'label' => __('Save'),
            'class' => 'save primary',
            'data_attribute' => [
                'mage-init' => [
                    'buttonAdapter' => [
                        'actions' => [
                            [
                                'targetName' => 'targetname.targetname',
                                'actionName' => 'youractionname',
                                'params' => [
                                    false
                                ]
                            ]
                        ]
                    ]
                ],
                'form-role' => 'save',
            ],
            'url' => null,
            'sort_order' => 90,
        ];
    }


}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.