在 Ruby on Rails 中禁用文本框? [英] Disable a Text Box in Ruby on Rails?

查看:32
本文介绍了在 Ruby on Rails 中禁用文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码:

        <% generate_bullets = Bullet.all %>
        <% generate_bullets.shuffle.first(4).each do |t| %>
        <%= f.text_field, :bullets, :class => 'text_field disabled' %>

我想使用嵌入式 ruby​​ 禁用文本框,但我无法这样做.如果我能就我所面临的情况得到任何帮助,将不胜感激.

I want to disable a text box using embedded ruby, and am unable to do so. If I could receive any help on the situation I'm facing, it would be very greatly appreciated.

在我禁用文本框后,我想让一个按钮从数据库表项目符号"中生成四个随机 ID,并以数组格式将它们打印在禁用的文本框中,然后利用这四个打印的 ID 将它们发布到创建的页面.对此有任何帮助会更好.

After I disable the text box I want to have a button generate four random ID's from the database table "bullets" and print them on the disabled text box in an array format, and utilize those four printed ID's to post them onto a created page. Any help with that would be even better.

推荐答案

如果我没看错,请告诉我:您正试图从一开始就禁用 HTML 中的文本字段.是吗?

Let me know if I'm reading this right: you're trying to disable the text field from the get-go in the HTML. Is that right?

如果是这样,disabled 不是一个类;这是它自己的属性.

If so, disabled isn't a class; it's its own attribute.

<%= f.text_field, :bullets, :class => 'text_field', :disabled => true %>

这篇关于在 Ruby on Rails 中禁用文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆