自定义HTML属性需要自定义帮助程序吗?

编程入门 行业动态 更新时间:2024-10-28 13:22:42
本文介绍了自定义HTML属性需要自定义帮助程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试创建一个在输入中具有一些自定义数据属性的表单:

I'm trying to create a form with some custom data attributes on the inputs:

<input type="text" data-family="Dinosaurs">

这似乎是通过jquery轻松进行前端访问(哈哈!)的一种好方法:

This seemed like a nice clean way to have easy front-end access (haha!) with jquery:

$("[data-family='Dinosaurs']").doSomething()

问题是我无法获得Rails(3.0.3)来呈现该属性.

The problem is I can't get Rails (3.0.3) to render the attribute.

<%= f.text_field :question, :id=>"poll_question", :class=>"BigInput", :style=>"width:98%;", :attributes=>"data-submit_clear='1'" %>

我尝试了许多排列,但都无济于事,并且找不到如何执行此操作的示例.我是否需要修改text_field助手以支持任何自定义属性?

I've tried many permutations to no avail and can't find an example of how to do this. Do I need to modify the text_field helper to support any custom attributes?

推荐答案

糟糕.只是

<%= f.text_field :question, :id=>"poll_question", :class=>"BigInput", :style=>"width:98%;", 'data-submit_clear'=>'1' %>

更多推荐

自定义HTML属性需要自定义帮助程序吗?

本文发布于:2023-11-13 14:02:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584514.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   属性   程序   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!