Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. define(
  2. [
  3. 'jquery',
  4. 'Magento_Ui/js/modal/modal'
  5. ],
  6. function ($) {
  7. "use strict";
  8. //creating jquery widget
  9. $.widget('vendor.modalForm', {
  10. options: {
  11. modalForm: '#modal-form',
  12. modalButton: '.open-modal-form'
  13. },
  14. _create: function () {
  15. this.options.modalOption = this._getModalOptions();
  16. this._bind();
  17. },
  18. _getModalOptions: function () {
  19. /**
  20. * Modal options
  21. */
  22. var options = {
  23. type: 'popup',
  24. responsive: true,
  25. title: '',
  26. };
  27.  
  28. return options;
  29. },
  30. _bind: function () {
  31. var modalOption = this.options.modalOption;
  32. var modalForm = this.options.modalForm;
  33.  
  34. $(document).on('click', this.options.modalButton, function () {
  35. //Initialize modal
  36. $(modalForm).modal(modalOption);
  37. //open modal
  38. $(modalForm).trigger('openModal');
  39. });
  40. }
  41. });
  42.  
  43. return $.vendor.modalForm;
  44. }
  45. );
  46.  
  47. <div style="display:none;" id="modal-form">
  48. <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>
  49. // here should go the code for the form
  50. </div>
  51. <a class="action open-modal-form" href="#" title="Modal">
  52. <span>Review Product</span>
  53. </a>
  54. <script type="text/x-magento-init">
  55. {
  56. ".open-modal-form": {
  57. "Vendor_Module/js/modal-form": {}
  58. }
  59. }
  60. </script>
  61.  
  62. <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>
  63.  
  64. <?php echo $this->getLayout()->createBlock("MagentoReviewBlockForm")->setTemplate("Magento_Review::form.phtml")->toHtml(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement