gpt4 book ai didi

javascript - 将变量从 link_to 传递到 Rails 中的模态

转载 作者:行者123 更新时间:2023-11-28 07:29:55 24 4
gpt4 key购买 nike

我有一个包含属性电子邮件的结果表。我希望能够将对象传递到 Rails 中的模态。似乎无法传递该对象,以便我可以在我的模式中调用它。

index.html.erb

<div class="modal fade bs-example-modal-lg" id="email-template-user-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<%= render "shared/email_template_user"%>
</div>
</div>
</div>

<p class="email">
<% @banker_assignments.each do |application| %>
<%= link_to application.loan_application.email, lp_banker_assignments_email_status_path(application), class: 'email-template-user-modal', id: "email-template-user-id", :data => { :toggle => "modal", :target => "#email-template-user-modal", :email => application.loan_application.email, :id => application.loan_application.id, :application => application } %>
<%= end %>
</p>

assignments_controller.rb

def email_status
ap params
end

routes.rb

post '/lp_banker_assignments/email_status' => 'lp_banker_assignments#email_status'
put '/lp_banker_assignments/email_status' => 'lp_banker_assignments#email_status'
get '/lp_banker_assignments/email_status' => 'lp_banker_assignments#email_status'

_email_template_user.html.erb

<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Compose Email</h4>
</div>
<div class="panel-body">
<div class="row">
<div class="form-group col-md-12">

<%= form_tag :action => 'email_status', class: 'form-horizontal' do %>
<div class="">
<div class="col-md-3">Recipient</div>


<div class="col-md-9">
<%= email_field_tag "recipient", <%= application.email %>, class: " string optional form-control"%>
</div>
<div class="col-md-3">Cc to:</div>
<div class="col-md-9">
<%= email_field_tag "cc_to", <%= application.second_email %>, class: " string optional form-control" %>
</div>

<div class="col-md-3">
Subject
</div>

<div class="col-md-9">
<%= text_field "subject", "", class: "subject string optional form-control" %>
</div>

<div class="col-md-3">
Content
</div>

<div class="col-md-9">
<%= text_field "content", ""%>

</div>
<div class="col-md-3"></div>
<div class="col-md-9">
<%= submit_tag %>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>

我已经尝试了很多jquery选项,但我似乎不知道如何将对象从我的index.html.erb获取到我的模态视图。

感谢任何帮助

最佳答案

<%= link_to application.loan_application.email, 
lp_banker_assignments_email_status_path(application),
class: 'email-template-user-modal', id: "email-template-user-id",
:data => { :toggle => "modal", :target => '#email-template-user-modal_' + application.loan_application.id,
:email => application.loan_application.email, :id => application.loan_application.id, :application => application } %>

您的模态代码

<div class="modal fade" id="<%= 'email-template-user-modal_%s' % [application.loan_application.id] %>">
<div class="modal-dialog">
...content
</div>
</div>

关于javascript - 将变量从 link_to 传递到 Rails 中的模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29229225/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com