Javascript API
Want to create some custom behavior for your Zigpoll?
Last updated
Want to create some custom behavior for your Zigpoll?
If you have a single page website you can still use Zigpoll. All you need to do is run the following code immediately after you change a page within your app.
window.Zigpoll.refresh();If you want to toggle your Zigpoll programmatically (like when a user clicks a button) use the following function.
window.Zigpoll.toggle();This will toggle your Zigpoll open and closed.
Alternatively you can use:
window.Zigpoll.open();
window.Zigpoll.close();To open and close the Zigpoll respectively.
To trigger some behavior once the Zigpoll has loaded, use the onload parameter of the Zigpoll object. For example:
window.Zigpoll.onload = function () { console.log('Zigpoll loaded') }This will run once immediately after the Zigpoll has been loaded on your page.
To run some behavior when a respondent closes the Zigpoll — for example after they finish a survey — set the onClose parameter of the Zigpoll object:
onClose is called with the respondent's submitted answers: an array with one entry per answered slide. Each entry contains the slide (the question) and the response (the submitted answer); multi-select questions also include a responses array.
Last updated
window.Zigpoll.onClose = function (responses) { console.log('Zigpoll closed', responses) }window.Zigpoll.onClose = function (responses) {
responses.forEach(function ({ slide, response }) {
console.log(slide.title, response);
});
}
