【问题标题】:Rails text_field_tag, input type missing in productionRails text_field_tag,生产中缺少输入类型
【发布时间】:2017-06-09 15:13:34
【问题描述】:

我在 rails 4.2.7 中使用 materialize,当我使用 rails text_field_tag 时,input type="text" 属性在生产环境中不可用,而它在开发环境中可用

<div class="input-field col l6 m6 s12 clear-margin">
   <%= text_field_tag :address,"", :class => "location-field", id: 
   "address" %>
   <label for="address">Address</label>
</div>

开发中的输出如下

<input type="text" name="address" id="address" value="" class="location-field" data-parsley-id="6097">

但是在生产中输入类型属性没有出现,谁能帮我解决这个问题

提前致谢。

【问题讨论】:

    标签: ruby-on-rails material-design


    【解决方案1】:

    使用 jquery 解决了这个问题。

    if($("input:not([type])").length>0){
      $( "input:not([type])").on('focus',function({$(this).siblings("label").addClass("active")})
      $( "input:not([type])").on('blur',function(){
       if (!$(this).val() ) { 
         $(this).siblings("label").removeClass("active")
       }
     })
    }
    

    【讨论】:

      猜你喜欢
      • 2014-07-06
      • 2015-07-12
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-03
      • 2015-07-27
      • 2017-04-08
      相关资源
      最近更新 更多