admin管理员组文章数量:1405888
I integrated client side validations with rails4 using the new branches available using the following gems
gem 'simple_form', '~> 3.0.0.rc'
gem 'client_side_validations', github: "bcardarella/client_side_validations", :branch => "4-0-beta"
gem 'client_side_validations-simple_form', git: 'git://github/saveritemedical/client_side_validations-simple_form.git'
gem "jquery-rails"
I also added the required JavaScript as the following
//= require jquery
//= require jquery_ujs
//= require foundation
//= require rails.validations
//= require rails.validations.simple_form
//= require_tree .
//= require_self
I created this test form in order to see if it works
= simple_form_for(@post, :validate => true) do |f|
= f.error_notification
.form-inputs
= f.input :title, :required => true
.form-actions
= f.button :submit
of course in the model, it was
validates :title, presence: true
The problem is I can't figure our why it is not working, while JavaScript Console shows the following error:
Uncaught TypeError: Cannot read property 'add' of undefined
I integrated client side validations with rails4 using the new branches available using the following gems
gem 'simple_form', '~> 3.0.0.rc'
gem 'client_side_validations', github: "bcardarella/client_side_validations", :branch => "4-0-beta"
gem 'client_side_validations-simple_form', git: 'git://github./saveritemedical/client_side_validations-simple_form.git'
gem "jquery-rails"
I also added the required JavaScript as the following
//= require jquery
//= require jquery_ujs
//= require foundation
//= require rails.validations
//= require rails.validations.simple_form
//= require_tree .
//= require_self
I created this test form in order to see if it works
= simple_form_for(@post, :validate => true) do |f|
= f.error_notification
.form-inputs
= f.input :title, :required => true
.form-actions
= f.button :submit
of course in the model, it was
validates :title, presence: true
The problem is I can't figure our why it is not working, while JavaScript Console shows the following error:
Uncaught TypeError: Cannot read property 'add' of undefined
Share
asked Jul 14, 2013 at 1:50
Mohammad Abu MusaMohammad Abu Musa
1,1332 gold badges11 silver badges33 bronze badges
2 Answers
Reset to default 3These gems involve a lot of configurations and ordering to be proper. Instead of explaining the whole procedure i can give you a link in SO where a similar problem was solved. Please do check it out and follow the same.
ruby-on-rails client_side_validation simple_form javascript error
Hope it helped !
The problem appear to be in the order of the javascript, just change the order it will work fine
本文标签: javascriptClient Side Validations and Rails4Stack Overflow
版权声明:本文标题:javascript - Client Side Validations and Rails4 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744927600a2632696.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论