cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We want to make our Community work for you and we need your help. Take our short survey!
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Triggering the Embedder using JavaScript

Highlighted

Triggering the Embedder using JavaScript

New member | Level 2
New member | Level 2
var options = {
      // Shared link to Dropbox file
      link: "https://www.dropbox.com/sh/keptcjl08q3wsid/AACui966iXcXPbagCJ2py2L-a?dl=0",
      file: {
        // Sets the zoom mode for embedded files. Defaults to 'best'.
        zoom: "best" // or "fit"
      },
      folder: {
        // Sets the view mode for embedded folders. Defaults to 'list'.
        view: "list" // or "grid"
        headerSize: "normal" // or "small"
      }
    }
    Dropbox.embed(options, element);

In addition to the above code and the embed code snippet is there anything else I need to get the dropbox embedder to work? Embedding via anchor links works, but I can't trigger it using the javascript code above in order to customize it a bit.

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Triggering the Embedder using JavaScript

Dropboxer
Dropboxer

Thanks! Yes, you'll also need to define "element" which will depend on your page, but should be the element on your page where you want to put the Embedder.

 

For example, if you have an element on your page like this:

<div id="folder_container"></div>

 

Then you might define 'element' like this:

var element = document.getElementById("folder_container");

View solution in original post

4 Replies 4
Highlighted

Re: Triggering the Embedder using JavaScript

Dropboxer
Dropboxer

What error, if any, do you get in the JavaScript Console when you try this?

 

From what I can see, it looks like it may just be a syntax error. You're missing a comma here:

// view: "list" // or "grid"

It should be:

view: "list", // or "grid"
Highlighted

Re: Triggering the Embedder using JavaScript

New member | Level 2
New member | Level 2

Thanks for responding. I get the following error in console.

Uncaught ReferenceError: element is not defined

Highlighted

Re: Triggering the Embedder using JavaScript

Dropboxer
Dropboxer

Thanks! Yes, you'll also need to define "element" which will depend on your page, but should be the element on your page where you want to put the Embedder.

 

For example, if you have an element on your page like this:

<div id="folder_container"></div>

 

Then you might define 'element' like this:

var element = document.getElementById("folder_container");

View solution in original post

Highlighted

Re: Triggering the Embedder using JavaScript

New member | Level 2
New member | Level 2

Thanks. That did the trick.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?