开发者

textarea character count in Rails

开发者 https://www.devze.com 2023-01-07 23:08 出处:网络
I want to use observe_field to give me the character count of the textarea, updated as you type. What am I doing wrong here?

I want to use observe_field to give me the character count of the textarea, updated as you type. What am I doing wrong here?

<div class="field">
  <%= observe_field :micropost_content,
      :function => "$(开发者_如何学C'micropost_content').value.length" %>
  <%= f.text_area :content %>
</div>


If you don't set the frequency option it becomes event based (onchange.) Try:

<%= observe_field :micropost_content, :frequency => 1,
      :function => "$('micropost_content').value.length" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号