Sometimes you might need to be able to run a callback function on something like a popup. When you create the popup, in the instantiation object you can give it a callback property with a function to be run, but then how do you trigger it?
That's where t.notifyParent('done')
comes into play. Calling this method from that popup will trigger Trello to run the callback.
1 2var onDone = function (t, opts) { console.log('Hey There'); }; window.TrelloPowerUp.initialize({ 'show-settings': function (t, opts) { return t.popup({ callback: onDone, title: 'Settings', url: './settings.html', height: 184 }); } });
The script on our settings page might look like:
1 2var t = window.TrelloPowerUp.iframe(); t.render(function () { // do some stuff }); document.getElementById('save').addEventListener('click', function () { // will cause the callback that was included when this // popup was created to be run return t.notifyParent('done'); });
Rate this page: