Can div with contenteditable=true be passed through form?

前端 未结 4 928
失恋的感觉
失恋的感觉 2020-11-30 03:56

Can

Some Text
be used instead of texarea and then passed trough form someh
4条回答
  •  情书的邮戳
    2020-11-30 04:43

    Without JS it doesn't seem possible unfortunately. If anyone is interested I patched up a solution with VueJS for a similar problem. In my case I have:

    In "data" you can set a default value for mainMessage, and in methods I have:

    methods: {
      updateMainMessage: function(e) {
        this.mainMessage = e.target.innerText;
      }
    }
    

    "d-none" is a Boostrap 4 class for display none. Simple as that, and then you can get the value of the contenteditable field inside "gift[main_message]" during a normal form submit for example. I'm not interested in formatting, therefore "innerText" works better than "innerHTML" for me.

提交回复
热议问题