Lifecycle events
The popover ships with different hooks for deep customization. Events are triggered through the lifecycle of the component where you can tie in custom functionality and code.
While users interact with the UI events like onInit, onOpen, onPosition ... will be triggered.
For a complete list of events go to the documentation See available lifecycle events →
Demo
onClose: function (event, inst) { /* Your custom event handler goes here */ },
onDestroy: function (event, inst) { /* Your custom event handler goes here */ },
onInit: function (event, inst) { /* Logic running on component init */ },
onOpen: function (event, inst) { /* Your custom event handler goes here */ },
onPosition: function (event, inst) { /* Logic for component positioning */ },
Event log
Welcome to our website!
Have fun navigating through the demos.
JSHTMLCSS
mobiscroll.setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
var popup = mobiscroll.popup('#demo-popup-hooks', {
display: 'anchored',
anchor: document.getElementById('demo-popup-open-btn'),
buttons: ['ok', 'cancel'],
onClose: function (args) {
// Logic running on popup close
console.log('onClose', args);
},
onDestroy: function (args) {
// Logic running on component destroy
console.log('onDestroy', args);
},
onInit: function (args) {
// Logic running on component init
console.log('onInit', args);
},
onOpen: function (args) {
// Logic running on popup open
console.log('onOpen', args);
},
onPosition: function (args) {
// Logic for component positioning
console.log('onPosition', args);
},
});
document.getElementById('demo-popup-open-btn').addEventListener('click', function () {
popup.open();
});
<div class="mbsc-form-group">
<div class="mbsc-button-group-block">
<button mbsc-button id="demo-popup-open-btn">Open popup</button>
</div>
</div>
<div id="demo-popup-hooks" style="display:none;">
<div class="mbsc-align-center mbsc-padding">
<img src="https://img.mobiscroll.com/demos/logo-noshadow.jpg">
<h4>Welcome to our website!</h4>
<p>Have fun navigating through the demos.</p>
</div>
</div>
/* style */