in placeholder on Rails 3? I have textarea that has Markdown support, and I would like to show a placeholder to show what kind of...">

How to use <br/"> in placeholder on Rails 3?

I have textarea that has Markdown support, and I would like to show a placeholder to show what kind of formatting Markdown likes, but when you type <br /> in placeholder, <br /> displayed in the text. I would prefer this to create a new line, if possible.

I am using Rails 3, below is the code I am using:

<%= f.text_area :info, :placeholder => "if you want you can <br /> add a link by doing this: [text](http://link.com) it pretty neat aye? or you could use bold by doing this: **bold text is cool**" %>

+6
source share
3 answers

According to the specification, the placeholder attribute cannot contain any line breaks or carriage returns.

+1
source

As Logan says, although you can find some hacks in a similar question here:

Can you have multi-line HTML5 placeholder text in <textarea>?

0
source

Here are a few more related hackers with multi-line placeholders, I followed the example in the answer below to make my workaround: Insert line break inside placeholder attribute in text box?

For rails, I thought this was useful if you want the gem to deal with placeholders: jquery-placeholder-rails .

However, you will need a forked version of jQuery-placeholder that supports the new line: jQuery-Placeholder-Newlines

0
source

Source: https://habr.com/ru/post/890790/


All Articles