Ruby on rails 如何在RubyonRails中隐藏标签
我正在尝试创建一个动态页面并使用CoffeScriptRuby on rails 如何在RubyonRails中隐藏标签,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,我正在尝试创建一个动态页面并使用CoffeScript class Requistion < ActiveRecord::Base end class RequistionsController < ApplicationController def show @requistion = Requistion.find(params[:id]) end def create @requistion = Requistion.new(user_param
class Requistion < ActiveRecord::Base
end
class RequistionsController < ApplicationController
def show
@requistion = Requistion.find(params[:id])
end
def create
@requistion = Requistion.new(user_params)
@requistion.save
end
def index
@requistions = Requistion.all
end
def new
@requistion = Requistion.new
end
private
def user_params
params.require(:requistion).permit(:object)
end
end
查看代码:
<%= f.label :info, :'text', class: "col-md-4 control-label" %>
<%= f.text_field :info, class: "form-control" %>
<%= f.label :info, :'text', class: "col-md-4 control-label hidden" %>
<%= f.text_field :info, class: "form-control hidden" %>
下面是JQuery代码
$'class\u info'.parent.hide
该字段是隐藏的,但标签不是。有什么问题吗?查看代码:
<%= f.label :info, :'text', class: "col-md-4 control-label" %>
<%= f.text_field :info, class: "form-control" %>
<%= f.label :info, :'text', class: "col-md-4 control-label hidden" %>
<%= f.text_field :info, class: "form-control hidden" %>
请显示实际定义id类信息的代码。我所看到的只是你想使用它,但是你在HTML中到底在哪里定义它。你能更具体地描述一下代码吗?对不起,我不知道插入代码对你有多大的帮助?