For standard textareas I use this plugin to create a placeholder. How can I extend tinymce so that this works in this way also.
E.g the default value is read from the
The answers above were not working for me, but here's my (for me) working code based on the answers above and using onchange_callback. Hope it helps someone!
onchange_callback : function(ed){
var tinymce_placeholder = $('#' + ed.id).attr("placeholder");
setTimeout(function () {
var content = ed.getContent().replace(/|<\/p>/g, '');
if (content == '') {
ed.setContent(tinymce_placeholder);
}
}, 200);
},
setup: function (ed) {
// Set placeholder
var tinymce_placeholder = $('#' + ed.id);
if (tinymce_placeholder.length) {
ed.onInit.add(function (ed) {
var cont = ed.getContent();
if (cont.length == 0) {
ed.setContent(tinymce_placeholder.attr("placeholder"));
}
});
ed.onMouseDown.add(function (ed, e) {
var content = ed.getContent().replace(/
|<\/p>/g, '');
if (content == tinymce_placeholder.attr("placeholder")) {
ed.setContent('');
}
});
}
}