I am trying to load popup widget , admin specifies it will be unload on ready . Where can I specify it must pop unload or on ready ?
define([
'jquery',
'Magento_Ui/js/modal/modal',
'mage/cookies'
], function ($, modal) {
'use strict';
$.widget('devall.popupManager', {
/**
* creating popup
*/
_create: function () {
var self = this,
popupOptions = {
responsive: true,
title: this.options.popupTitle,
buttons: false,
modalClass: 'popup-devnewsletter',
autoOpen: true,
/**
* setting a cookie
*/
closed: function () {
self._setCookie();
}
};
if (!$.cookie('popup_cookie')) {
modal(popupOptions, this.element);
}
this.element.find('form').submit(function (e) {
e.preventDefault();
if ($(this).validation('isValid')) {
$.ajax({
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: 'json',
type: 'POST',
showLoader: true,
/**
* Just a function
*/
success: function () {
self.element.modal('closeModal');
self._setCookie();
}
});
}
});
},
/**
* cookie function
*/
_setCookie: function () {
var expDate = new Date();
expDate.setTime(expDate.getTime() + 3650000 * 60 * 1000);
$.cookie('popup_cookie', 1, {
expires: expDate
});
}
});
return $.devall.popupManager;
});