Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - layout
- <div id="base">
- <%= link_to "Ajax!", remote: true, class: "getUsers" %>
- <div class="wrapper"></div>
- </div>
- - controller
- class UsersController < ApplicationController
- layout false
- def index
- @users = User.all
- end
- end
- - view
- <div id="userCtrl">
- <ul>
- <% @users.each do |u| %>
- <li><%= u.name %></li>
- <% end %>
- </ul>
- </div>
- - css
- #userCtrl {
- # CSS for userCtrl
- }
- - js
- $(function() {
- $(document).on("ajax:success", '#userCtrl .getUsers', function(q, data, xhr){
- $("#base .wrapper").html(data);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement