mrzaizai2233 / magento2-dev-log

0 stars 0 forks source link

Javascript widget #5

Open mrzaizai2233 opened 6 years ago

mrzaizai2233 commented 6 years ago

https://magento.stackexchange.com/questions/202055/what-is-data-post-data-action-in-magento-2-can-anyone-explain-wishlist-functio https://devdocs.magento.com/guides/v2.2/javascript-dev-guide/widgets/widget_confirm.html As you can see in widget lib/web/mage/dataPost.js

$.each(this.options.postTrigger, function (index, value) {
    events['click ' + value] = '_postDataAction';
});

On click to elements which satisfy the selectors ['a[data-post]', 'button[data-post]', 'span[data-post]'] will be created and submitted form with params, specified in data-post attribute value.

Additionally, you can specify confirmation message

if (params.data.confirmation) {
    uiConfirm({
        content: params.data.confirmationMessage,
        actions: {
            /** @inheritdoc */
            confirm: function () {
                $form.appendTo('body').hide().submit();
            }
        }
    });
} else {
    $form.appendTo('body').hide().submit();
}