Here is my HTML and JS:
<div id="mybutton" class="button">
click
</div>
<div id="testcontent">
blah
</div>
<script>
// <![CDATA[
require([
'jquery',
'jquery/ui',
'Magento_Ui/js/modal/modal'
], function ($) {
$(function () {
$('#mybutton').on('click', function(){
$('#testcontent').modal({
title: 'My Title',
autoOpen: true
});
});
});
});
// ]]>
</script>
The Problem is: the modal works only once. After closing it the button does not spawn a second modal.