I would like to put different choosers to one page with different extensions options. So I inserted a <div class="dropbox-chooser"></div>
to the different positions in my site. Then I wrote the following function to my head(for testing):
window.onload = function() {
if (document.getElementsByClassName("dropbox-chooser")) {
for(var i = 0; i < document.getElementsByClassName("dropbox-chooser").length; i++){
if (i === 0) {
options.extensions = ['.zip','.exe','.rar','.7zip','.php','.html','.css','.js'];['.3gp','.3gpp','.3gpp2','.avi','.mov','.mp4','.wmv','.m4v','.mpg','.mkv','.mpeg','.vob','.flv','.mts','.m2t','.ts','.dv'];
button = Dropbox.createChooseButton(options);alert(options.toSource());
document.getElementsByClassName("dropbox-chooser")[i].appendChild(button);
}
if (i === 2) {
options.extensions = ['.3gp','.3gpp','.3gpp2','.avi','.mov','.mp4','.wmv','.m4v','.mpg','.mkv','.mpeg','.vob','.flv','.mts','.m2t','.ts','.dv'];
button = Dropbox.createChooseButton(options);alert(options.toSource());
document.getElementsByClassName("dropbox-chooser")[i].appendChild(button);
}
}
}
}
and the two choosers are rendered in the right place but when I click one of the chooser buttons, the extensions option is always the last one (.3gp...) although the options.toSource() function shows the right object content for every button.
Can you please help me? Thanks a lot!
Dennis
I believe the Chooser doesn't look at the options
object until the Chooser is actually opened.
You should just pass in a different object each time.
EDIT
Here's what I would suggest:
var choosers = document.getElementsByClassName('dropbox-chooser');
for (var i = 0; i < choosers.length; i++) {
var options = {
// ...
};
if (i === 0) {
options.extensions = ['.zip', '.exe' /* ... */];
} elif (i === 2) {
options.extensions = ['.3gp', '.3gpp' /* ... */];
}
choosers[i].appendChild(Dropbox.createChooseButton(options));
}