$(function() {
var script = document.createElement('script');
script.id="filepicker";
script.type="text/javascript";
script.src="//api.filepicker.io/v1/filepicker.js";
var body=document.querySelectorAll("body")[0]; ;
body.appendChild(script);
var ButtonsArea = document.querySelectorAll('.frm-buttons')[0];
var textArea = document.getElementById('text_editor_textarea');
var button = document.createElement('span');
var divText=document.createTextNode("Upload File");
button.id="newDoc";
button.setAttribute("onclick","getPick()");
button.appendChild(divText);
ButtonsArea.appendChild(button);
function getPick(){
filepicker.setKey('AWpNcAmH9TmiWtEgHsFwBz');
filepicker.pick({
mimetypes: ['text/*'],
services:['COMPUTER'],
maxSize:50*1024
},function(FPFile) {
var docFile = FPFile.url;
textArea.value=textArea.value+'[url]'+FPFile.url+'+'+FPFile.filename+'[/url]';
});
}
});
my getPick() function is being said it is not defined is there something that I am missing from all of the JavaScript, maybe the JavaScript timing is off since everything is being created dynamically?
addEventListener
and pass the function as an object, that's the beauty of JS. – elclanrs Jun 1 '13 at 23:05