This error is generated when i want to show popup when page load in magento2. Here I mentioned code of popup. In popupWidth and popupHeight there are height and width value store.
require(['jquery','Magento_Ui/js/modal/modal'],function($,modal)
{
var options =
{
type: 'popup',
responsive: true,
innerScroll: true,
slideshowSpeed: 8000,
};
var popupWidth = $("#popupWidth").val();
var popupHeight = $("#popupHeight").val();
var popup = modal(options, $('#popup-modal'));
$('#popup-modal').css("display","block");
$('#popup-modal').modal('openModal');
$("footer button").remove();
$(".modal-footer").css("border-top","0");
$(".modal-popup._inner-scroll .modal-inner-wrap").css("width", popupWidth);
$(".modal-popup._inner-scroll .modal-inner-wrap").css("height", popupHeight);
function close()
{
$('#popup-modal').modal('closeModal');
}
});
But it display cannot call methods on modal prior to initialization; attempted to call method 'openModal' this error message.
How to solve it?