rails4 bootstrap3 ajax模式不起作用

时间:2014-09-14 14:05:57

标签: jquery ruby-on-rails ajax twitter-bootstrap-3

当我使用Boostrap 2时,模态效果很好。但我改变了我的模板,这个模板使用bootstrap 3和模态不起作用。你能让我知道如何解决这个问题吗?

_form.html.erb

中的

<%= render 'place' %>
<%= render 'modal' %>

在_place.html.erb

<%= form_tag(getlatlng_path,remote: true) do  %> 
    <%= text_field_tag :search_place %>
    <%= submit_tag "search", class: "btn btn-success" %>
<% end %>
在_modal.html.erb

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title">Modal title</h4>
      </div>
    <div class="modal-body">
      <p id="modal1">body…</p>
      <p id="modal2"></p>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal">close</button>
      <button class="btn btn-primary", id="map-select", style="display: none", onclick="getValue()">Select</button>
    </div>
   </div>
  </div>
</div>
<_>在reports_controller.rb

def latlng
  ~~~
  respond_to do |format|
    format.html { redirect_to @report}
    format.js
  end
end

在latlng.js.erb

~~~
$(".modal-body").html(content);
$(".modal-title").html('<%= $query %> search result');
$('#myModal').modal('show');

之前

$('#myModal').modal('show');

一切运作良好,模态体和模态标题改变正确,但模态不具有吸引力。 你能让我知道如何解决这个问题吗?

在application.js

//= require bootstrap/jquery
//= require jquery_ujs
//= require bootstrap/bootstrap.min
//= require bootstrap/jquery.prettyPhoto
//= require bootstrap/jquery.isotope.min
//= require bootstrap/main
//= require bootstrap/wow.min
//= require bootstrap/jquery-1.10.2.min
//= require profile
//= require turbolinks

在application.css

 *= require bootstrap/bootstrap.min
*= require bootstrap/font-awesome.min
*= require bootstrap/animate.min
*= require bootstrap/prettyPhoto
*= require bootstrap/main
*= require bootstrap/responsive

在控制台

Started POST "/getlatlng" for 127.0.0.1 at 2014-09-15 00:33:17 +0900
Processing by ReportsController#latlng as JS
Parameters: {"utf8"=>"✓", "search_place"=>"kisti", "commit"=>"serach"}
User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Rendered reports/latlng.js.erb (1.1ms)
Completed 200 OK in 81ms (Views: 3.2ms | ActiveRecord: 0.2ms)

请帮帮我〜

0 个答案:

没有答案