# Magento 2: Uncaught Error: cannot call methods on modal prior to initialization; attempted to call method 'show' when calling bootstrap modal

I am getting error when I am calling modal like this

setTimeout(function() { $('#site-pop-up').modal('show'); }, 2000);  Error in console: Uncaught Error: cannot call methods on modal prior to initialization; attempted to call method 'show' Anyone have solution for this? Thanks • how did you solved ? i am also getting same error – sumeet bajaj May 8 at 8:16 • @sumeet Please share your code – Shiwani May 8 at 9:46 ## 1 Answer Add your code in require so that it will execute with jquery and modal is ready require([ 'jquery', 'Magento_Ui/js/modal/modal' ], function($){
setTimeout(function() {
jQuery('#site-pop-up').modal('show');
}, 2000);
});

• Thanks for the reply. This is working for me . I have defined in my requirejs-config.js like this "shim": { 'bootstrap': { 'deps': ['jquery','jquery/ui','Magento_Ui/js/modal/modal'] }, 'jquery-storageapi': { 'deps': ['jquery'] }, – Shiwani Apr 11 at 9:48
• That's great, welcome :) +1 for the appreciation – Shoaib Munir Apr 11 at 9:51
• @ShoaibMunir not working for me – sumeet bajaj May 8 at 8:16
• Can you please share your code? – Shiwani May 8 at 9:45
• – sumeet bajaj May 8 at 10:06