Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- define(
- [
- 'jquery',
- 'Magento_Ui/js/modal/modal'
- ],
- function ($) {
- "use strict";
- //creating jquery widget
- $.widget('vendor.modalForm', {
- options: {
- modalForm: '#modal-form',
- modalButton: '.open-modal-form'
- },
- _create: function () {
- this.options.modalOption = this._getModalOptions();
- this._bind();
- },
- _getModalOptions: function () {
- /**
- * Modal options
- */
- var options = {
- type: 'popup',
- responsive: true,
- title: '',
- };
- return options;
- },
- _bind: function () {
- var modalOption = this.options.modalOption;
- var modalForm = this.options.modalForm;
- $(document).on('click', this.options.modalButton, function () {
- //Initialize modal
- $(modalForm).modal(modalOption);
- //open modal
- $(modalForm).trigger('openModal');
- });
- }
- });
- return $.vendor.modalForm;
- }
- );
- <div style="display:none;" id="modal-form">
- <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>
- // here should go the code for the form
- </div>
- <a class="action open-modal-form" href="#" title="Modal">
- <span>Review Product</span>
- </a>
- <script type="text/x-magento-init">
- {
- ".open-modal-form": {
- "Vendor_Module/js/modal-form": {}
- }
- }
- </script>
- <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>
- <?php echo $this->getLayout()->createBlock("MagentoReviewBlockForm")->setTemplate("Magento_Review::form.phtml")->toHtml(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement