Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 部分未加载rails jquery_Javascript_Jquery_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Javascript 部分未加载rails jquery

Javascript 部分未加载rails jquery,javascript,jquery,ruby-on-rails,ruby,ruby-on-rails-3,Javascript,Jquery,Ruby On Rails,Ruby,Ruby On Rails 3,我的新.js.erb就像 $("#product1-modal").html("<%= escape_javascript(render 'new') %>") $("#product1-modal").modal("show") $(“#产品1模式”).html(“”) $(“#产品1模式”)。模式(“显示”) _new.html.erb-like <div class="modal-header"> <h3>New Product</h3&g

我的新.js.erb就像

$("#product1-modal").html("<%= escape_javascript(render 'new') %>")
$("#product1-modal").modal("show")
$(“#产品1模式”).html(“”)
$(“#产品1模式”)。模式(“显示”)
_new.html.erb-like

 <div class="modal-header">
 <h3>New Product</h3>
 </div>
 <%= render "form" %>

新产品
和my_form.html.erb

       <%= form_for @product1, remote: true, html: { class: "form-horizontal", style: "display:inline;" } do |f| %>
<div class="modal-body">
<ul class="errors"></ul>

<div class="control-group">
<%= f.label :name, class:"control-label" %>
<div class="controls">
<%= f.text_field :name %>
</div>
</div>
<div class="control-group">
<%= f.label :price, class: "control-label" %>
<div class="controls">
<%= f.text_field :price %>
</div>
</div>
</div>
<div class="modal-footer">
<%= f.submit class: "btn btn-primary" %>
<%= link_to "Cancel", "#", class: "btn", data: {dismiss: "modal"} %>
</div>
<% end %>

    我的部分表单没有加载 我得到的响应看起来不错,但页面未加载 有人能帮我吗

    当我点击新按钮时,我得到的回应是

    $("#product1-modal").html("<div class=\"modal-header\">\n    <h3>New Product<\/h3>\n    <\/div>\n        <form accept-charset=\"UTF-8\" action=\"/product1s\" class=\"form-horizontal\" data-remote=\"true\" id=\"new_product1\" method=\"post\" style=\"display:inline;\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"mUNwn0fJoZ4lCbJjy8Ju8V78xp+/mjXoZkoqbh0EeOw=\" /><\/div>\n    <div class=\"modal-body\">\n    <ul class=\"errors\"><\/ul>\n     \n    <div class=\"control-group\">\n    <label class=\"control-label\" for=\"product1_name\">Name<\/label>\n    <div class=\"controls\">\n    <input id=\"product1_name\" name=\"product1[name]\" size=\"30\" type=\"text\" />\n    <\/div>\n    <\/div>\n    <div class=\"control-group\">\n    <label class=\"control-label\" for=\"product1_price\">Price<\/label>\n    <div class=\"controls\">\n    <input id=\"product1_price\" name=\"product1[price]\" size=\"30\" type=\"text\" />\n    <\/div>\n    <\/div>\n    <\/div>\n    <div class=\"modal-footer\">\n    <input class=\"btn btn-primary\" name=\"commit\" type=\"submit\" value=\"Create Product1\" />\n    <a href=\"#\" class=\"btn\" data-dismiss=\"modal\">Cancel<\/a>\n    <\/div>\n<\/form>\n")
    $("#product1-modal").modal("show")
    
    $(“\product1 modal”).html(“\n新产品\n\n\n\n\n\n\n名称\n\n\n\n\n价格\n\n\n\n\n\n\n\n取消\n\n\n\n”
    $(“#产品1模式”)。模式(“显示”)
    
    index.html.erb

        <div class="container">
    <div class="well">
    <%= link_to "New Product1", new_product1_path, remote: true, class: "btn btn-primary" %>
    </div>
    <div class="new-product1"></div>
    <table class="table table-bordered table-striped">
    <thead>
    <tr>
    <th>Name</th>
    <th>Price</th>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </thead>
    <tbody class="product1-index">
    <%= render "index" %>
    </tbody>
    </table>
    </div>
    <div id="product1-modal" class="modal hide fade"></div>
    
    
    名称
    价格
    
    看起来你给错id了

    在新的.js.erb文件中,它应该是“#产品模式”,而不是“#产品1模式”

    $("#product-modal").html("<%= escape_javascript(render 'new') %>")
    $("#product-modal").modal("show")
    
    $(“#产品模式”).html(“”)
    美元(“#产品模式”)。模式(“展示”)
    

    更新新的.js.erb文件

    可能不是这样,但如果新的.js.erb中没有分号,则可能会导致问题

    如果没有,请尝试添加它们

    $("#product1-modal").html("<%= escape_javascript(render 'new') %>");
    $("#product1-modal").modal("show");
    
    $(“#产品1模式”).html(“”);
    美元(“#产品1模态”)。模态(“显示”);
    
    同时共享(#product1 modal)div的html。它应该有“模态”类