【发布时间】:2015-10-07 04:49:50
【问题描述】:
我不明白我为什么会遇到这个问题。好像我的函数 hiddenField() 没有被读取。
我的表格:
f.input :contact, :as => :radio, :collection => ["slide", "formulaire de contact", "map", "video"], input_html: {:class => "select", :onblur => "hiddenField()"}
f.input :title_map, label: I18n.t('title_map'), input_html: {:class => "hidden_title"}, placeholder: "Entrer un titre pour la map"
我的脚本:
var ready;
ready = function() {
function hiddenField() {
$(".select").on( 'click', function() {
document.getElementsByClassName("hidden_title").removeAttribute("input");
};
};
hiddenField();
};
$(document).ready(ready);
$(document).on('page:load', ready);
谢谢。
编辑:
对不起,我忘记了。我的表格在 admin/page.rb 中。我使用 ActiveAdmin。
【问题讨论】:
-
因为你已经在另一个函数内部定义了函数,所以不能从外部访问它
-
将函数
hiddenField放在ready()之外,或者在ready()末尾添加window.hiddenField = hiddenField -
我在外面也有同样的问题...
标签: javascript ruby-on-rails forms activeadmin