markdown 隐藏字段form_for属性

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 隐藏字段form_for属性相关的知识,希望对你有一定的参考价值。

* In the case of recreating your own WYSIWYG editor, the `:content` attribute is not created as a
`form_for` object.
* It is instead a `div` that contains an attribute called `contenteditable = 'true'`
* How do you **connect** the attribute to this div?
    * Create a `<%= f.hidden_field(:content) %>` within the form (using the name of the attribute)
* In order to attach the contents of the div to the hidden field tag, you will need javascript!

```javascript
$("[name='compForm']").submit () ->
	$("input[name='content_page[page_content]']:hidden").val(document.getElementById("textBox")
	.innerHTML)
```

* Add a name attribute to the form, or use the form's ID
    * When the form is submitted, add a submit event listener to the form
    * Query for the hidden field
    * Obtain the innerHTML value of the content editable div and give that the value for the hidden
    input field

以上是关于markdown 隐藏字段form_for属性的主要内容,如果未能解决你的问题,请参考以下文章

解析rails中的表单隐藏字段

如何将jquery克隆行附加到隐藏字段

Rails隐藏字段未定义方法“合并”错误

markdown Drupal有条件地显示/隐藏字段。

在不同位置放置Rails Form_For字段

Rails form_for 具有相同属性的嵌套和关联资源已填充文本