Created
April 8, 2014 20:15
-
-
Save Polyrhythm/10184363 to your computer and use it in GitHub Desktop.
I want callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vi = new versalInterface(); | |
var Gadget = function() { | |
var createListeners = function() { | |
vi.on('attached', this.render()); | |
// I just want to set a general re-render listener when config changes | |
vi.on('attributesChanged', function(data) { | |
for (var key in data) { | |
this.config[key] = data[key]; | |
} | |
// here I have to special case in the event that I get an image | |
if (data.asset) { | |
document.body.innerHTML += /* picture markup */; | |
} | |
this.render(); | |
}.bind(this)); | |
} | |
this.render = function() { | |
var gadgetHtml = ''; | |
document.body.innerHTML = ''; | |
gadgetHtml = '<button class="upload">upload</button>'; | |
document.body.innerHTML = gadgetHtml; | |
document.querySelector('upload').addEventListener('click', function(e) { | |
e.preventDefault(); | |
vi.trigger('requestAsset', { /* ... */ }, /* why can't I put a callback here */); | |
}) | |
return this; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because it will be handled by
vi.on('attributesChanged', function(){})