I'm trying to add a validation in tinymce editor. The condition is without giving all the mandatroy input user can't submit the form. It was all okay till I added table plugin in tinymce. After adding table in the editor, when I give some input on that table, my code can't read that value from the table, but if i give that value outside of the table then the validation works fine. what i've understood that, for some reason, the editor is not getting the table tag values. And this is my code:
var moduleTypesMap = {};
$.each(moduleTypesJson, function (index, item){
moduleTypesMap[item.name] = item;
moduleTypesMap[item.name]['placeholders'] = item.placeholders.split(',');
});
tinymce.init({
selector: '#textarea',
plugins: 'table',
toolbar: 'table tabledelete | tableprops tablerowprops tablecellprops | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol'
});
$submitButton.on('click', function (){
var body = tinymce.get('textarea').getContent(); //gets the whole content of the table
var isBodyValid = true;
var type = $template.val(); //my dropdown values
$.each(moduleTypesMap[type].placeholders, function (index, item){
if (body.indexOf(item) === -1)
isBodyValid=false;
});
if(isBodyValid){
$form.trigger('submit');
} else {
bootbox.alert("please give all placeholders");
}
});
the way I'm giving values in the editor is :
{name}, {roll}, {school}.
but if i give the value {name} on table then it can't read the value. that time item {name} gets index(body.indexOf(item) === -1)
got -1 whereas outside the table it got value greater than 1. I dont know why table values are not getting the index number greater than 1.
[N.B] Solved:
actually the input I was transferring there were some mismatch that's why didnt work. But now its solved.
tags or others but not getting values