4

以下のようなMagento 2 Modal Widgetを使用しようとしていますが、機能しませんでした。エラーも表示されません。Magento 2 Modal Widget

<script> 
    require(
     [ 
      'jquery', 
      'Magento_Ui/js/modal/modal' 
     ], 
     function(
      $, 
      modal 
     ) { 
      $("#ship_now").click(function() { 
       $('#shipNowContent').modal({ 
        autoOpen:false, 
        clickableOverlay:true, 
        type:'popup', 
        title:'Hello', 
       }); 
      }); 
     } 
    ); 
</script> 

この点についてお手伝いできますか?

答えて

5

これを試してみてください。 Magento 2.0で実装されています。

<button type="button" id="openModel" class="btn btn-primary">Open Model</button> 
<div id="myModel"> 
    <h1>Title</h1> 
    <div>Content.....</div> 
</div> 
<script> 
    require(
     [ 
      'jquery', 
      'Magento_Ui/js/modal/modal' 
     ], 
     function($,modal) { 
      var options = { 
       type: 'popup', 
       responsive: true, 
       innerScroll: true, 
       title: 'popup mpdal title', 
       buttons: [{ 
        text: $.mage.__('Continue'), 
        class: '', 
        click: function() { 
         this.closeModal(); 
        } 
       }] 
      }; 
      var popup = modal(options, $('#myModel')); 
      $("#openModel").on("click",function(){ 
       $('#myModel').modal('openModal'); 
      }); 
     } 
    ); 
</script> 
+0

を?また、私はこのものがmagento.stackexchange.comに掲載されたことを願っています。 – camdixon

0

これを試してみてください..あなたはこのコードを入れてください

var options = { 
       type: 'popup', 
       responsive: true, 
       innerScroll: true, 
       title: 'Newsletter', 
       buttons: [{ 
         text: jQuery.mage.__('Continue'), 
         class: '', 
         click: function() { 
          this.closeModal(); 
         } 
        }] 
      }; 
      jQuery("#subscriber_button").on('click', function() { 
       modal(options, jQuery('#popup-modal')); 
       jQuery("#popup-content").modal("openModal"); 
      });