I have a form and i must check element in textarea/ div with trumbowyg.
$("#test").keyup(function() {
var val = $(this).val();
if (val.match(/{event_title}/g)) {
$("p.eventTagTitle").addClass("true");
} else {
$("p.eventTagTitle").removeClass("true");
}
if (val.match(/{event_form}/g)) {
$("p.eventTagForm").addClass("true");
} else {
$("p.eventTagForm").removeClass("true");
}
if (val.match(/{event_author}/g)) {
$("p.eventTagAuthor").addClass("true");
} else {
$("p.eventTagAuthor").removeClass("true");
}
});
but
in trumbowyg not works
similar solution in trumbowyg not work when add text to div
Trumbowyg editor have special event: tbwchange
(from http://alex-d.github.io/Trumbowyg/documentation.html).
You should just replace one line
$("#test").keyup(function() {
to
$("#test").on('tbwchange', function() {
Done on fiddle: http://jsfiddle.net/f1m33312/6/