JavaScript events
Instead, Scalar 2 includes a custom event, ‘pageLoadComplete’. This event will fire when Scalar 2 finishes manipulating the DOM.
The ‘mediaElementComplete’ fires when media elements are created:$(document).ready(function() {
$('body').on('pageLoadComplete',function() {
// Do something to the DOM, such as change the "This page is tagged by" text
$('.has_tags').prev().text('This is the new text');
});
});
The ‘widgetElementLoaded’ fires when widgets are created:$(document).ready(function() {
$('body').on('mediaElementComplete',function(mediaElement) {
// Do something with the mediaElement
});
});
$(document).ready(function() {
$('body').on('widgetElementLoaded',function() {
// Do something with the widget
});
});