step 1: I use table.insertRow().insertCell() will create a "DayContent_2" textarea input then i use CKEDITOR.replace( 'DayContent_2' ) is work !
step 2: I table.deleteRow the step 1's "DayContent_2" textarea input !
step 3: I use table.insertRow().insertCell() create "DayContent_2" textarea input again, but CKEDITOR.replace( 'DayContent_2' ) isn't work ! it alert "undefined" but the "DayContent_2" textarea input is exist !
My English isn't very good and help me please , thanks a lot!
Create a "DayContent_X" textarea input javascript code
Delete a "DayContent_X" textarea input javascript code
dayday table html code
step 2: I table.deleteRow the step 1's "DayContent_2" textarea input !
step 3: I use table.insertRow().insertCell() create "DayContent_2" textarea input again, but CKEDITOR.replace( 'DayContent_2' ) isn't work ! it alert "undefined" but the "DayContent_2" textarea input is exist !
My English isn't very good and help me please , thanks a lot!
Create a "DayContent_X" textarea input javascript code
function createTextArea(){ var mytable = $("dayday"); var mycount = mytable.rows.length; var row = mytable.insertRow(); var td1=row.insertCell(); td1.className='wbg'; var tmp1='<textarea name="DayContent_'+mycount+'" style="width:100%;" rows="8" id="DayContent_'+mycount+'" ></textarea>'; td1.innerHTML = tmp1; try { CKEDITOR.replace( 'DayContent_'+mycount ); } catch(e) { alert(e.description); } return true; }
Delete a "DayContent_X" textarea input javascript code
function deleteTextarea() { var myta=$("dayday"); var mycount = myta.rows.length; if(myta.rows.length-1>1) { myta.deleteRow(mycount-1); } else { alert("The last one!"); return; } }
dayday table html code
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#a0c5e9" id="dayday" name="dayday"> <tr> <td bgcolor="#FFFFFF"><input type="button" class="Button1" onclick="createTextArea()" value="insert" /> <input type="button" class="Button1" onclick="deleteTextarea()" value="delete" /></td> </tr> <tr> <td bgcolor="#FFFFFF"><textarea name="DayContent_1" rows="8" id="DayContent_1" style="width:100%;"></textarea></td> </tr> </table>
Re: About CKEDITOR.replace problem!
Re: About CKEDITOR.replace problem!
Look at http://nightly.ckeditor.com/4412/_samples/ajax.html
You have to destroy the instance to free it up for later use since they have same ids.
Re: About CKEDITOR.replace problem!
The right javascript code:
Thanks a lot!