主题: 请问怎么获取ajax方式创建的编辑器,并获取编辑器的对象 |
作者: 小浪子, 发布日期: 2012-07-16 16:24:33, 浏览数: 3478 |
请问怎么获取ajax方式创建的编辑器,并获取编辑器的对象
这断代码是我通过ajax方式创建的: <script type="text/javascript"> var strUpLoadPath = '../Inc/UpLoad.Asp?Action=SaveLoadMain&smode=1&sdir=6'; var editor_87507681775272473645; $(function() { $.getScript('../../Editor/kindeditor.js', function() { KindEditor.basePath = '../../Editor/'; editor_87507681775272473645 = KindEditor.create('#dContent1', { langType: 'zh_CN', width: '515px', height: '300px', minWidth: '515px', items: ["source", "|", "undo", "redo", "|", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "removeformat", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "/", "link", "unlink", "hr", "|", "fullscreen", "about"], uploadJson: strUpLoadPath }); }); }); </script> <table width="95%" border="0" cellpadding="4" cellspacing="1" class="table" id="87507681775272473645"> <tr class="table_title"> <td colspan="2"><span class="fl">第1天</span><span class="fr"><a href="javascript:void(0);" onClick="RemoveHtml('87507681775272473645');">移除</a></span></td> </tr> <tr class="tr"> <td class="left">行程:</td> <td><input name="dTitle" type="text" size="50" maxlength="100" /><input type="hidden" name="dDayId" value="0" /></td> </tr> <tr class="tr"> <td class="left">图片路径1:</td> <td><input name="dPic1" id="dPic11" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片1 " onClick="ShowWin('UpLoaddPic11','上传图片1','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic11',400,200,true);return false;" /></td> </tr> <tr class="ji"> <td class="left">图片链接1:</td> <td><input name="dPicUrl1" type="text" size="70" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">图片路径2:</td> <td><input name="dPic2" id="dPic21" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片2 " onClick="ShowWin('UpLoaddPic21','上传图片2','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic21',400,200,true);return false;" /></td> </tr> <tr class="tr"> <td class="left">图片链接2:</td> <td><input name="dPicUrl2" type="text" size="70" maxlength="100" /></td> </tr> <tr class="ji"> <td class="left">早餐:</td> <td><input name="dMeal0" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">午餐:</td> <td><input name="dMeal1" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">晚餐:</td> <td><input name="dMeal2" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">住宿:</td> <td><input name="dStay" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">交通:</td> <td><input name="dTraffic" type="text" size="50" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">行程简介:</td> <td><textarea name="dContent" id="dContent1" cols="65" rows="10"></textarea></td> </tr> </table> <script type="text/javascript"> var strUpLoadPath = '../Inc/UpLoad.Asp?Action=SaveLoadMain&smode=1&sdir=6'; var editor_07769837233558234651; $(function() { $.getScript('../../Editor/kindeditor.js', function() { KindEditor.basePath = '../../Editor/'; editor_07769837233558234651 = KindEditor.create('#dContent2', { langType: 'zh_CN', width: '515px', height: '300px', minWidth: '515px', items: ["source", "|", "undo", "redo", "|", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "removeformat", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "/", "link", "unlink", "hr", "|", "fullscreen", "about"], uploadJson: strUpLoadPath }); }); }); </script> <table width="95%" border="0" cellpadding="4" cellspacing="1" class="table" id="07769837233558234651"> <tr class="table_title"> <td colspan="2"><span class="fl">第2天</span><span class="fr"><a href="javascript:void(0);" onClick="RemoveHtml('07769837233558234651');">移除</a></span></td> </tr> <tr class="tr"> <td class="left">行程:</td> <td><input name="dTitle" type="text" size="50" maxlength="100" /><input type="hidden" name="dDayId" value="0" /></td> </tr> <tr class="tr"> <td class="left">图片路径1:</td> <td><input name="dPic1" id="dPic12" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片1 " onClick="ShowWin('UpLoaddPic12','上传图片1','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic12',400,200,true);return false;" /></td> </tr> <tr class="ji"> <td class="left">图片链接1:</td> <td><input name="dPicUrl1" type="text" size="70" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">图片路径2:</td> <td><input name="dPic2" id="dPic22" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片2 " onClick="ShowWin('UpLoaddPic22','上传图片2','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic22',400,200,true);return false;" /></td> </tr> <tr class="tr"> <td class="left">图片链接2:</td> <td><input name="dPicUrl2" type="text" size="70" maxlength="100" /></td> </tr> <tr class="ji"> <td class="left">早餐:</td> <td><input name="dMeal0" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">午餐:</td> <td><input name="dMeal1" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">晚餐:</td> <td><input name="dMeal2" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">住宿:</td> <td><input name="dStay" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">交通:</td> <td><input name="dTraffic" type="text" size="50" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">行程简介:</td> <td><textarea name="dContent" id="dContent2" cols="65" rows="10"></textarea></td> </tr> </table> <script type="text/javascript"> var strUpLoadPath = '../Inc/UpLoad.Asp?Action=SaveLoadMain&smode=1&sdir=6'; var editor_47254280091767466801; $(function() { $.getScript('../../Editor/kindeditor.js', function() { KindEditor.basePath = '../../Editor/'; editor_47254280091767466801 = KindEditor.create('#dContent3', { langType: 'zh_CN', width: '515px', height: '300px', minWidth: '515px', items: ["source", "|", "undo", "redo", "|", "fontname", "fontsize", "|", "forecolor", "hilitecolor", "bold", "italic", "underline", "strikethrough", "removeformat", "|", "justifyleft", "justifycenter", "justifyright", "justifyfull", "/", "link", "unlink", "hr", "|", "fullscreen", "about"], uploadJson: strUpLoadPath }); }); }); </script> <table width="95%" border="0" cellpadding="4" cellspacing="1" class="table" id="47254280091767466801"> <tr class="table_title"> <td colspan="2"><span class="fl">第3天</span><span class="fr"><a href="javascript:void(0);" onClick="RemoveHtml('47254280091767466801');">移除</a></span></td> </tr> <tr class="tr"> <td class="left">行程:</td> <td><input name="dTitle" type="text" size="50" maxlength="100" /><input type="hidden" name="dDayId" value="0" /></td> </tr> <tr class="tr"> <td class="left">图片路径1:</td> <td><input name="dPic1" id="dPic13" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片1 " onClick="ShowWin('UpLoaddPic13','上传图片1','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic13',400,200,true);return false;" /></td> </tr> <tr class="ji"> <td class="left">图片链接1:</td> <td><input name="dPicUrl1" type="text" size="70" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">图片路径2:</td> <td><input name="dPic2" id="dPic23" type="text" size="70" maxlength="100" /> <input type="button" class="bginput" value=" 上传图片2 " onClick="ShowWin('UpLoaddPic23','上传图片2','Inc/UpLoad.Asp?Action=UpLoadMain&stype=1&smode=0&sdir=6&inst=dPic23',400,200,true);return false;" /></td> </tr> <tr class="tr"> <td class="left">图片链接2:</td> <td><input name="dPicUrl2" type="text" size="70" maxlength="100" /></td> </tr> <tr class="ji"> <td class="left">早餐:</td> <td><input name="dMeal0" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">午餐:</td> <td><input name="dMeal1" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">晚餐:</td> <td><input name="dMeal2" type="text" size="20" maxlength="50" /></td> </tr> <tr class="tr"> <td class="left">住宿:</td> <td><input name="dStay" type="text" size="20" maxlength="50" /></td> </tr> <tr class="ji"> <td class="left">交通:</td> <td><input name="dTraffic" type="text" size="50" maxlength="100" /></td> </tr> <tr class="tr"> <td class="left">行程简介:</td> <td><textarea name="dContent" id="dContent3" cols="65" rows="10"></textarea></td> </tr> </table>
里面的: editor_后面的值。是我用随机数生成
里面有写: |
作者: Roddy, 发布日期: 2012-07-16 23:19:47 |
用最新代码的话,执行以下代码就可以。
KindEditor.sync('#dContent1'); KindEditor.sync('#dContent2'); KindEditor.sync('#dContent3'); |
回复 |
作者: 小浪子, 发布日期: 2012-07-16 23:50:33 |
回复Roddy:我这个也是动态创建的。。 如:textarea[name="dContent"]获取到他之后。取ID。然后再用你发的哪个自动创建。 只有name一样,要不你加下我QQ。我告诉你我这个是怎么创建的。。 QQ:939881475 |
回复 |
作者: Roddy, 发布日期: 2012-07-17 10:24:27 |
KindEditor.sync支持多个编辑器的,如果只有name可以这样,这样可以把匹配的几个编辑器都同步了。 KindEditor.sync('textarea[name="dContent"]'); 当然如果你用jQuery,也可以直接传入jQuery对象。
KindEditor.sync($('textarea[name="dContent"]')); |
回复 |
作者: 小浪子, 发布日期: 2012-07-17 11:51:26 |
回复Roddy:太谢谢了。
|
回复 |