Javascript无法在部分

时间:2017-02-28 21:23:01

标签: javascript jquery html ruby-on-rails

我有一个模态,其中包含用于创建对象的表单和用于更新对象中数据的模态。由于某种原因,创建对象模式的javascript正在运行,但更新模式不会呈现应用程序javascript。我不确定为什么会发生这种情况。以下是我的代码:

index.html.erb

<%= form_for(@suggested_invite, remote: true) do |f| %>
      <div class="modal fade" id="mynewsuggestedinvite" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        Modal with form in it
      </div>
  <% end %>
<tbody id="content"><%= render @suggested_invites %></tbody>\\ Where the 
list of objects exists and where the modal that shows the objects exists

_suggested_invite.html.erb

<%= form_for(@suggested_invite, :method => :put, remote: true) do |f| %>
  <div class="modal fade" id="mynewsuggestedinvite" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    Modal with form filled out with object data
  </div>
  

dashboard.js.erb

$(document).ready(function(){

Javascript Code

});

dashboard.js.erb中的Javascript仅适用于index.html.erb,而不适用于_suggested_invite.html.erb。我想让dashboard.js.erb javascript代码在部分页面和主页面中都有效。任何帮助将非常感谢!如果我能提供更多信息,请告诉我

0 个答案:

没有答案