Reputation: 555
I'm using the Remodal - modal Window script, but How can I configure when that window closes it doesnot appear anymore for the visitor?
Upvotes: 0
Views: 298
Reputation: 169
Using js-cookie it would work something like this:
$(document).on('closed', '.remodal', function (e) {
console.log('closed' + (e.reason ? ', reason: ' + e.reason : ''));
Cookies.set('remodal_closed', '1', { expires: 7 });
});
Then check that the cookie doesn't exist before opening remodal:
$(document).ready(function() {
if(!Cookies.get('remodal_closed')) {
setTimeout(function() {
$('[data-remodal-id=modal]').remodal().open();
}, 3000); //set a more realistic time
}
});
You might also need to set the cookie on confirmation:
$(document).on('confirmation', '.remodal', function () {
console.log('confirmation');
Cookies.set('remodal_closed', '1', { expires: 7 });
});
Upvotes: 0
Reputation: 6439
use the event given in documentation and set some cookie, before showing modal to the user check that cookie
$(document).on('closed', '.remodal', function (e) {
console.log('closed');
// set cookie here
console.log(e.reason);
});
Upvotes: 1