Skip to content
Shobhit Sharma edited this page Nov 20, 2019 · 8 revisions

Embedo exposes following functions that you need after including the library:

.load()

The .load() function is all what you need to embed third party content given under following arguments.

embedo.load(<HTMLElement{}>, <URL[string|Array]>, <options[{}*optional]>)

Due to incongruent third party restrictions regarding sizes, additional functionality called automagic is added, which basically auto-scales the container to fit within DOM without overflowing (enabled by default unless strict is set to true).

Example

embedo
 .load(HTMLElement, 'my://url/goes/here', { centerize: true })
 .done(data => {})
 .fail(err => {})

.render()

For single instance with similar arguments, render method can alternatively be called which returns a callback instead.

embedo.render(<HTMLElement{}>, <URL[string]>, <options[{}*optional]>, <callback|Function>)

.domify()

Embeds content in having data-embedo-url attribute to it. It will be called during init automatically, but also can be re-initialized with following call. Additional options can be passed with data-embedo-* suffix as shown in example here.

embedo.domify()

.refresh()

The embedo.refresh() method can be called explicitly when you have a change or resize event, which re-calculates the dimensions of generated content.

// Refresh single container
embedo.refresh(document.getElementById('my-element-id'));

// Refresh all embedo instances
embedo.refresh();

.destroy()

The embedo.destroy() method can be called explicitly when wish to remove and unbind embedo instance(s).

// Destroy single container
embedo.destroy(document.getElementById('my-element-id'));

// Destroys all embedo instances
embedo.destroy();

Clone this wiki locally