Hi,
I'm using the ckeditor in the following situation:
I want to uncheck the Event (parent checkbox)
- Disable all childs checkbox (ok);
- Clear all childs checkbox (ok);
- Remove the correspondent field variable from the body of email, but only the first one was removed;
I commented the code below and works fine with textarea element:
$(document).ready(function () {
$('textarea#txtBody').ckeditor({
height: 225
});
});
So, my question is: there is some bug on val() implementation?
// this function is fired on click of Event Chk
// <input id="chkEvent" type="checkbox" onclick="chkEnable(this, '3');" />
function chkEnable(chk, type) {
$("input[name='chk" + type + "'][type=checkbox]").attr({
disabled: !chk.checked
});
if (!chk.checked) {
$("input[name='chk" + type + "'][type=checkbox]:checked").each(function () {
$(this).prop({ 'checked': false });
// Simulate a click in each child checkbox thas was checked
chkClick($(this));
});
}
}
// this funtion is fired on each child check box, loaded dynamically
function chkClick(objChk) {
if ($(objChk).prop('checked')) {
$("#txtBody").val($("#txtBody").val() + $(objChk).val());
} else {
var localBody = $("#txtBody").val();
localBody = replaceAll(localBody, $(objChk).val(), "");
// alert(localBody);
$("#txtBody").val(localBody);
}
}
function replaceAll(str, token, newtoken) {
while (str.indexOf(token) != -1) {
str = str.replace(token, newtoken);
}
return str;
}