[英]Laravel - get the textarea value from view within TinyMCE
My problem: 我的问题:
Everything is appearing within the view as expected, but once the user has edited the text field, I want to then re-upload it to the database. 一切都将按预期方式出现在视图中,但是一旦用户编辑了文本字段,我想将其重新上传到数据库。 However, within the Controller, I cannot
get
the text within the 'textarea'. 但是,在Controller中,我无法在“ textarea”中
get
文本。
Current HTML set up within my view is: 在我看来,当前设置的HTML是:
{!! Form::open(array('route' =>
array('updateReport', $report->first()->id), 'role'=>'form','id'=>'updateReport')) !!}
<textarea class="form-control" id="report" name="report" rows="15">
{{ $report->first()->html }}</textarea>
<button type="submit" class="btn btn-labeled btn-success" aria-hidden="true">
<span class="btn-label">
<i class="glyphicon glyphicon-save"></i></span> Update Report</button>
{!! Form::close() !!}
Javascript section to initialise the TinyMCE: 用于初始化TinyMCE的Javascript部分:
<script type="text/javascript">
tinymce.init({
selector: '#report',
menubar: false,
browser_spellcheck: true,
});
</script>
I have tried: 我努力了:
Input::all() and Input::get('report')
- both return null
. Input::all() and Input::get('report')
-都返回null
。
How can I get the raw HTML that's newly edited and stored "behind the scenes", surely there must be a simple way? 我如何才能获得新编辑的原始HTML,并在“幕后”存储这些HTML,肯定有一种简单的方法?
Many thanks in advance. 提前谢谢了。
如果只需要担心一个字段, tinymce.activeEditor.getContent()
应该可以解决问题
You can use the setup
call back to bind a change
event to the editor which will trigger a save. 您可以使用
setup
回调将change
事件绑定到编辑器,这将触发保存。 This places the modified content back in the original textarea
allowing you to post it to your script. 这会将修改后的内容放回原始
textarea
使您可以将其发布到脚本中。
<script type="text/javascript">
tinymce.init({
selector: '#report',
setup: function (editor) {
editor.on('change', function () {
tinymce.triggerSave();
});
},
menubar: false,
browser_spellcheck: true
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.