Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor JS code and added JS component file #17527

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
<input name="form_key" type="hidden" value="<?= $block->escapeHtml($block->getFormKey()) ?>" />
<?= $block->getChildHtml('form') ?>
</form>


<script>
require(['jquery', "mage/mage"], function(jQuery){

jQuery('#edit_form').mage('form').mage('validation', {validationUrl: '<?= /* @escapeNotVerified */ $block->getValidationUrl() ?>'});

});
<script type="text/x-magento-init">
{
'#edit_form': {
"Magento_Ui/catalog/product/edit/attribute": {
validationUrl: '<?= /* @escapeNotVerified */ $block->getValidationUrl() ?>'
}
}
}
</script>
<?= /* @escapeNotVerified */ $block->getFormScripts() ?>
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
<form action="<?= /* @escapeNotVerified */ $block->getSaveUrl() ?>" method="post" id="attributes-edit-form" class="attributes-edit-form" enctype="multipart/form-data">
<?= $block->getBlockHtml('formkey') ?>
</form>
<script>
require(['jquery', "mage/mage"], function(jQuery){

jQuery('#attributes-edit-form').mage('form')
.mage('validation', {validationUrl: '<?= /* @escapeNotVerified */ $block->getValidationUrl() ?>'});

});
<script type="text/x-magento-init">
{
"#attributes-edit-form": {
"Magento_Ui/catalog/product/edit/attribute": {
validationUrl: '<?= /* @escapeNotVerified */ $block->getValidationUrl() ?>'
}
}
}
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'jquery',
'mage/mage'
], function ($) {
'use strict';

return function (config, element) {

$(element).mage('form').mage('validation', {
validationUrl: config.validationUrl
});
};
});