Register to receive events
Cincopa provides a simple way to register and handle events using its API. Events allow you to customize and enhance the functionality of your media galleries. Whether you want to track user interactions, control gallery behavior, or add new features, event registration can help.
There are two scenarios to consider when registering events:
Scenario 1: When Cincopa's main library (libasync.js
) is already loaded.
cincopa.registerEvent("cp_evt_mediaplay", "runtime.*");
function cp_evt_mediaplay(name, data, gallery) {
if (name == "runtime.on-args") // make sure this event is runtime.on-load-html
gallery.args.allow_search = "yes";
}
Scenario 2: When the library is not loaded yet.
var cincopa = cincopa || {};
cincopa.registeredFunctions = cincopa.registeredFunctions || [];
cincopa.registeredFunctions.push({
func: function (name, data, gallery) {
gallery.args.allow_search = "yes";
}, filter: "runtime.on-args"
});