Javascript 条件远程:根据验证为true
我有一个部分Javascript 条件远程:根据验证为true,javascript,ruby-on-rails,ajax,Javascript,Ruby On Rails,Ajax,我有一个部分\u form.html.haml中的表单,它被呈现为模态。我正在努力做到以下几点: 如果记录可以保存,请重定向到其他页面 否则,使用验证错误消息呈现模式 除了记录无效时,重定向到其他页面不起作用之外,其他一切都正常 我在\u form.html.haml中有以下内容,它被呈现为模态 = bootstrap4_form_for([:admin, donation], remote: true, html: { multipart: true, id: 'manual_donation
\u form.html.haml
中的表单,它被呈现为模态。我正在努力做到以下几点:
\u form.html.haml
中有以下内容,它被呈现为模态
= bootstrap4_form_for([:admin, donation], remote: true, html: { multipart: true, id: 'manual_donations', autocomplete: 'nope'}) do |f|
# form with submit_button which calls `create` action of `donations_controller.rb`
这是我的new.js.erb
,它呈现了上述模式:
$('#newDonation').modal('hide');
$('#newDonation, .modal-backdrop').remove();
$('body').append("<%= j render partial: 'donation_modal' %>");
$('#newDonation').modal('show')
当我单击带有有效记录的模式的submit按钮时,页面不会重定向,我在控制台上收到以下消息:
Processing by Admin::DonationsController#index as JS
-----------
No template found for Admin::DonationsController#index, rendering head :no_content
我有
app/views/admin/investments/
下的视图index.html.haml
。当我从\u form.html.haml
中删除remote:true
时,重定向工作正常。但是,在这种情况下,使用验证错误消息呈现new.js.erb
将不起作用。我真的不知道如何处理这种情况。这个index.html.haml
在哪里?它必须在app/views/admin/investments/下。它在app/views/admin/investments/下。当我从表单中删除remote:true
时,重定向工作
Processing by Admin::DonationsController#index as JS
-----------
No template found for Admin::DonationsController#index, rendering head :no_content