Home >Backend Development >PHP Tutorial >php下使用kindeditor插件,用js始终获取不到内容,。
是这样的,我把kindeditor封装到了smarty的插件,在另外一个页面中使用引入。
插件:function.html_kindeditor.php
<?phpfunction smarty_function_html_kindeditor(){ $editor1=' <script type="text/javascript"> var editor1; KindEditor.ready(function(K) { var editor1 = K.create(\'textarea[name="content1"]\', { cssPath : \'/wxy/view/plugins/code/prettify.css\', uploadJson : \'/wxy/view/upload_json.php\', fileManagerJson : \'/wxy/view/php/file_manager_json.php\', allowFileManager : true }); prettyPrint(); }); </script> <textarea name="content1" style="width:700px;height:200px;" id="content1"></textarea> <input type="button" value="提交" id="subContents"/> '; return $editor1;}
//jquery代码 $("#subContents").click(function(){ alert("字符串长度:"+($("#content1").val()).length+"类型:"+(typeof $("#content1").val())); });
allowFileManager : true, afterBlur:function(){ this.sync(); }
allowFileManager : true, afterBlur:function(){ this.sync(); }