openUploadWidget does not work
Hello
I am trying to use upgraded UI widget as described here:
but no success - I do not see the popup as expected. Here is my current code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>
<script>
//<![CDATA[
$('#upload_widget_multiple').click(function(e) {
e.preventDefault();
cloudinary.openUploadWidget({ cloud_name: 'dwakbbjk9', upload_preset: 'qp0yhsob' },
function (error, result) { console.log(error, result); });
});
//]]>
</script>
</head>
<body>
<div class="upload\_multiple\_images\_holder" style="margin-bottom: 20px">
<a href="#" id="upload\_widget\_multiple" class="cloudinary-button" style="color: #fff">Upload multiple images</a>
</div>
</body>
</html>
What am I doing wrong?
Thanks
Alex
-
The issue here is that the script can't see the element with the id of
upload_widget_multiple
yet. Therefore it isn't initiated.You can either put the script after the
</div>
part, or put all of it in$(function(){...})
so it waits for the DOM to load before initiating the script.-1
Post is closed for comments.
Comments
1 comment