Skip to content

Instantly share code, notes, and snippets.

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 seangwright/8767e2d388eaa58e9a255601cea62960 to your computer and use it in GitHub Desktop.
Save seangwright/8767e2d388eaa58e9a255601cea62960 to your computer and use it in GitHub Desktop.
ken120-mvc-vuejs-media-selection-editor.js
(function() {
"use strict";
let appRoot = undefined;
window.kentico.pageBuilder.registerInlineEditor("media-selection-editor", {
init: function(options) {
const editor = options.editor;
appRoot = new Vue({
el: `#${editor.attributes["data-id"].value}`,
data: {
hostUrl: editor.attributes["data-host-url"].value,
selectedMediaUrl: editor.attributes["data-current-media"].value,
propertyName: options.propertyName
},
methods: {
onDispatch: function (media) {
const widgetEvent = new CustomEvent("updateProperty", {
detail: {
name: this.propertyName,
value: media.fileGUID,
refreshMarkup: false
}
});
editor.dispatchEvent(widgetEvent);
this.selectedMediaUrl = media.permanentUrl;
}
}
});
},
destroy: function() {
if (appRoot) {
appRoot.$destroy();
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment