daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. google.maps.event.addListener(marker, 'click', function() {
  2.     $.ajax({
  3.       type: "GET",
  4.       url: "rooms/address_rooms",
  5.       dataType: "json",
  6.       data: {marker: { lat: marker.position.lat, lng: marker.position.lng }},
  7.       success: function(result){
  8.         $("#address_rooms").html(result);
  9.         $('#myModal').modal('show');
  10.       }
  11.     });
  12.   });
  13.  
  14. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  15.   <div class="modal-dialog modal-lg" role="document">
  16.     <div class="modal-content">
  17.       <div class="modal-body" id="address_rooms">
  18.         <%- @address_rooms.each do |room| %>
  19.           <%= room.title %>
  20.         <% end %>
  21.       </div>
  22.     </div>
  23.   </div>
  24. </div>
  25.    
  26. def address_rooms
  27.     marker = params[:marker]
  28.     @address_rooms = Room.where(latitude: marker[:lat].to_d.round(7), longitude: marker[:lng].to_d.round(7)).to_a
  29.     render json: @address_rooms
  30.   end
RAW Paste Data
Top