gpt4 book ai didi

ruby-on-rails - 将类 id 添加到 button_to 的 div

转载 作者:行者123 更新时间:2023-12-03 16:00:36 25 4
gpt4 key购买 nike

所以我的 button_to erb 标签给了我类似于下面的东西,我想知道是否可以通过在选项哈希中传递一些东西而不是使用 js 或手动添加 html 来向 div 添加一个 id:

<div>
<input id="button" type="submit" value="title">
<input name="auth_token">
</div>

我的按钮 erb 代码只是

<%= button_to title, {}, :id => "button"%>

最佳答案

从 3.2 开始, button_to 通过 html_options 键“form”接受表单属性的散列

<%= button_to title, {}, :form => { :id => "button" } %>

关于ruby-on-rails - 将类 id 添加到 button_to 的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11194777/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com