Custom cancel button on dialog

I’m sure this is an easy thing but I’m struggling to build a custom cancel button on a popup. I need a custom cancel button because I need some other code to run when the window is cancelled.

Here’s my error:

cannot call methods on popup prior to initialization; attempted to call method 'close’

Here’s my code:

var requestlistpopup = $('#requestlistpopup').mobiscroll4().popup({
          display: 'top',
          responsive: {small: {display: 'center'}},
          scrollLock: false,
          buttons: [{text: 'Cancel',
                      handler: function (event) {

The $(’#requestlistpopup’).popup(‘close’); part is giving me trouble. I’ve also tried.




Mobiscroll is not happy.

Hi Vincent, as I see, you’re using the v4 popup. In v4 the correct method name is hide.

Also, you need to call the methods through .mobiscroll (Calling .popup directly after the selector, and not using .mobiscroll4() before will invoke some other jQuery plugin, jQuery UI, Bootstrap, or something else, the error you get comes from there):


Or, since you save the reference to your instance, you can simply call:


Thank you!

(I’m getting a bit confused using both V4 and V5)