Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beckettkev/b97e73dbc878b03a8a98 to your computer and use it in GitHub Desktop.
Save beckettkev/b97e73dbc878b03a8a98 to your computer and use it in GitHub Desktop.
/*
Using the previous example, you can store the final Open XML snippet in a data attribute (e.g. data-base64) using jQuery
$this.data('base64', data)
and if you want to get the data again, use the following code:
$this.data('base64')
Where $this is a localised pointer to the image tag in jQuery. This code usually runs from a click event.
*/
if (!$this.hasClass('local')) {
//do what we did before (but remember to apply the local css class once it's finished...
} else {
//previously clicked on the image
Office.context.document.setSelectedDataAsync(
imageOXmlTemplate.replace(
'{Base64}',
$this.data('base64')
),
{ coercionType: "ooxml" },
function (asyncResult) {
if (asyncResult.status == "failed") {
//Again. Do something!
} else {
$this.removeClass('busy');
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment