3

Can you explain how to add popup(modal window) on button click in the adminhtml? I already create some phtml

<div id="messages">
<div class="messages">
    <?php foreach ($this->getCollection() as $reminder):
    ?>
    <div class="message message-notice notice">
        <div data-ui-id="messages-message-notice">Customer name - <?php echo $reminder->getCustomerName()
            ?>(Order ID #<?php echo $reminder->getOrderIncrementId() ?>); Date/Time - <?php echo $reminder->getDatetime()
            ?>; Due Date/Time - <?php echo $reminder->getDuedatetime() ?>; Assigned to User - <?php echo $reminder->getName() ?>;
            Note - <?php echo $reminder->getTitle() ?><button class="action- scalable primary">asd</button></div>
    </div>
    <?php endforeach; ?>
</div>

And I really need to know how to add modal action to the button.

7

Minimal example

<div id="messages">
       <div class="message"> MessageContents 
           <button class="primary">ClickMe</button>
       </div>
</div>
<script type="text/javascript">// <![CDATA[
require([
        'jquery',
        'Magento_Ui/js/modal/alert'
    ],
    function($, alert) {
       $('#messages').on('click', 'button.primary', function(event){
            alert({
               content: $(event.target).parent().text()
            })
       })
    }
);
// ]]></script>
</div>
  • :- i want magento2 default pop up with content can you please share working code, please share full code else it will confuse us so – Pradeep Kumar Oct 30 '15 at 8:29
  • its working i tried in front-end for that js is not included so through error – Pradeep Kumar Nov 4 '15 at 7:17
  • :- you answr is right but u need to add alert.js if you use in fronend – Pradeep Kumar Nov 4 '15 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.