我在用着this http://www.jqueryscript.net/text/Responsive-WYSIWYG-Text-Editor-with-jQuery-Bootstrap-LineControl-Editor.html所见即所得编辑器。该编辑器显示在引导程序的模式上。
<form action="<?php echo base_url('dashboard/submit_post'); ?>" method="POST" role="form" enctype="multipart/form-data">
<div class="form-group">
<label for="post_title">Post Title</label>
<input type="text" class="form-control" id="post_title" name="post_title" placeholder="Enter a title">
</div>
<div class="form-group">
<label for="post_content">Post Content</label>
<textarea name="post_content" id="post_content" cols="30" rows="3" class="form-control wyswig-editor"></textarea>
</div>
这个函数submit_post是这样的。
public function submit_post()
{
$this->process_post();
}
private function process_post()
{
$clean_post_title = $this->input->post('post_title');
$clean_post_content = $this->input->post('post_content');
$data = array(
'post_title' => $clean_post_title,
'post_content' => $clean_post_content
);
print_r($data);
}
其输出是显示帖子标题,但不显示帖子内容。它没有显示任何价值。我知道这一定是因为 WYSWIG 编辑器,所以我禁用了 wyswig 编辑器类,然后它工作得很好。然而,当我禁用 wyswig 编辑器类并发布时,我注意到一件事"Hello"作为 post_content 值,它被显示,然后我启用所见即所得编辑器并将该值更改为"Hello2",输出仍然显示为 Hello。编辑器以某种方式创建了自己的文本区域,因此显示的值是原始文本区域的值。请帮忙。
您使用的这个编辑器不会自动将内容插入到您的文本字段中,您必须通过 JavaScript 自行完成,如下所示:
$('#txtEditor').Editor("getText")
一般来说,这是一个糟糕的设计,我建议您使用其他引导所见即所得编辑器,例如:
- bootstrap-所见即所得 http://mindmup.github.io/bootstrap-wysiwyg/
- bootstrap-wysihtml5 http://jhollingworth.github.io/bootstrap-wysihtml5/
- 夏日笔记 http://summernote.org
我个人使用summernote
在我的项目中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)