diff --git a/test_app/app/assets/javascripts/application.js b/test_app/app/assets/javascripts/application.js index 79605af..224d3cc 100644 --- a/test_app/app/assets/javascripts/application.js +++ b/test_app/app/assets/javascripts/application.js @@ -52,3 +52,16 @@ Foos.prototype.otherAction = function(){}; var NotFoos = Paloma.controller('NotAdmin/Foos'); NotFoos.prototype.show = function(){}; NotFoos.prototype.otherAction = function(){}; + + +$(document).ready(function(){ + $('#js-ajax-link').on('click', function(e){ + e.preventDefault(); + + $.get($(this).prop('href'), function(response){ + $('#js-ajax-response').html(response); + Paloma.executeHook(); + Paloma.engine.start(); + }); + }); +}); diff --git a/test_app/app/controllers/main_controller.rb b/test_app/app/controllers/main_controller.rb index 047d481..0649a0b 100644 --- a/test_app/app/controllers/main_controller.rb +++ b/test_app/app/controllers/main_controller.rb @@ -40,6 +40,11 @@ class MainController < ApplicationController end + def ajax + render :ajax, :layout => false + end + + diff --git a/test_app/app/views/layouts/application.html.erb b/test_app/app/views/layouts/application.html.erb index cc6218b..e749b21 100644 --- a/test_app/app/views/layouts/application.html.erb +++ b/test_app/app/views/layouts/application.html.erb @@ -19,11 +19,15 @@
  • <%= link_to 'Main#basic_params', basic_params_main_index_path %>
  • <%= link_to 'Main#xml_response', xml_response_main_index_path %>
  • <%= link_to 'Main#file_response', file_response_main_index_path %>
  • +
  • <%= link_to 'Main#ajax', ajax_main_index_path, :id => 'js-ajax-link' %>

  • +
    +
    + <%= yield %> <%= insert_paloma_hook %> diff --git a/test_app/app/views/main/ajax.html.erb b/test_app/app/views/main/ajax.html.erb new file mode 100644 index 0000000..ede7752 --- /dev/null +++ b/test_app/app/views/main/ajax.html.erb @@ -0,0 +1,2 @@ +

    Main#AJAX

    +<%= insert_paloma_hook %> diff --git a/test_app/config/routes.rb b/test_app/config/routes.rb index d12e761..b2e76c8 100644 --- a/test_app/config/routes.rb +++ b/test_app/config/routes.rb @@ -12,6 +12,7 @@ TestApp::Application.routes.draw do get :js_response get :xml_response get :file_response + get :ajax end end