Sorry for the subject, I have no clue to take that problem in a simple phrase...
I guess I 'overcoded' a little bit.
My problem is that I want to execute at function publishOnWall ()
the function myDropzone.processQueue();
but I won't work of course because it's not defined before. The important thing is, that I must get the function (response)
part of the function puslishOnWall()
but I don't get it how I could do that, that I can take the responses of this function inside the submit button function.
Update: So the progress is: I click on the submit button, it checks if has already uploaded an image or not, then if I'm already logged in on facebook or not and then it calls the function to publish on the facebook wall. If the publishing on facebook wall was a success it uploads the image.
Have you any ideas how I could get this to work?
This is a excerpt of my code:
function publishOnFbWall() {
FB.ui({
method: 'stream.publish',
message: '',
attachment: {
name: "Demo",
caption: '',
description: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam.",
href: "url"
},
user_prompt_message: "Demo"
},
function (response) {
if (response && response.post_id) {
myDropzone.processQueue();
return true;
} else {
$('.dz-preview').addClass('dz-error');
$('.dz-error-message').text('Confirm post on your wall');
return false;
}
});
}
var $ = jQuery.noConflict();
$(document).ready(function () {
Dropzone.options.fbImageUploadForm = {
autoProcessQueue: false,
uploadMultiple: false,
parallelUploads: 100,
maxFiles: 1,
maxFilesize: 1, // MB
acceptedFiles: 'image/*',
previewsContainer: "#ImageUploadPreview",
previewTemplate: "<div class=\"dz-preview dz-file-preview\" data-dz-thumbnail>\n <div class=\"dz-details\">\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-info\">\n <div class=\"dz-success-mark\"><i class=\"fa fa-check-circle-o\"></i></div>\n <div class=\"dz-error-mark\"><i class=\"fa fa-bolt\"></i></div>\n <div class=\"dz-size\" data-dz-size></div>\n <a class=\"dz-remove\" data-dz-remove><i class=\"fa fa-times-circle-o\"></i></a>\n </div>\n </div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
clickable: '#ImageUploadPreview',
thumbnailWidth: 300,
thumbnailHeight: 300,
init: function () {
var submitButton = document.querySelector("#submit-all"),
myDropzone = this; // closure
submitButton.addEventListener('click', function () {
if ($('#ImageUploadPreview').children('div').hasClass('dz-preview dz-image-preview')) {
if (logIn()) {
publishOnFbWall();
} else {
logIn();
publishOnFbWall();
}
} else {
$('.dz-default span').replaceWith('<span class="no-image"><i class="fa fa-times"></i><br/>Upload an image</span>');
}
});