Skip to content

Instantly share code, notes, and snippets.

@roniemicro
Last active October 27, 2015 05:08
Show Gist options
  • Save roniemicro/68d2f04c949ae90d6a52 to your computer and use it in GitHub Desktop.
Save roniemicro/68d2f04c949ae90d6a52 to your computer and use it in GitHub Desktop.
Modify placeholder.js to allow dropdown(with dynamic item)
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.dialog.add("placeholder", function (a) {
var b = a.lang.placeholder;
a = a.lang.common.generalTab;
return {
title: b.title,
minWidth: 300,
minHeight: 80,
contents: [{
id: "info",
label: a,
title: a,
elements: [{
id: "name",
type: "select",
items : [ [ 'Insert placeholder', '' ] ],
style: "width: 100%;",
label: b.name,
"default": "",
required: !0,
onLoad: function(element) {
$('body').trigger(jQuery.Event('CKE.placeholder.onload'), [this]);
},
validate: CKEDITOR.dialog.validate.regex(/^[^\[\]<>]+$/, b.invalidName),
setup: function (a) {
this.setValue(a.data.name)
},
commit: function (a) {
a.setData("name", this.getValue())
}
}]
}]
}
});
//You cna then use the event to set add the dynamic data like this
jQuery(document).ready(function() {
jQuery("body")
.on('CKE.placeholder.onload', function(e, el){
el.add('Option 1', 'option1')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment