Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Container page helper when rendering partial using AJAX #734

Open
ramsaylanier opened this issue Sep 5, 2014 · 0 comments
Open

Using Container page helper when rendering partial using AJAX #734

ramsaylanier opened this issue Sep 5, 2014 · 0 comments

Comments

@ramsaylanier
Copy link

I'm using Browser CMS v. 3.5

I currently have a page template that initially renders a partial. On a button click, I'm replacing that partial with a different partial using ajax; however, the new partial has uses the "container" page helper. When it renders the new partial I get a "undefined method `container' " error. Below is some code:

layouts/templates/careers.html.erb

<%= render 'partials/header' %>
  <%= render 'partials/careers_header' %>    
    <div class="ajax-container">
      <div class="ajax-inner">
        <%= render 'careers/cultures' %>  #this is the initial partial in question
      </div>
    </div>


<%= render 'partials/footer' %>

config/routes.rb

...
get '/careers/:section', to: 'careers#section'
...

controllers/careers_controller.rb

class CareersController < ApplicationController

    def section
        @section = params[:section]
        respond_to do |format|
            format.js 
        end
    end
end

views/careers/section.js.erb

$('.ajax-inner').addClass('off-page');

setTimeout(function(){
    $('.ajax-inner').remove();
    $('.ajax-container').append('<div class="ajax-inner off-page"></div>');

       //renders the partial based on the instance variable passed in from the Careers controller
    $('.ajax-inner').html("<%= escape_javascript(render :partial => @section)%>"); 
}, 300);

setTimeout(function(){
    $('.ajax-inner').removeClass('off-page');
}, 600);

This all works well and good. I get a nice page transition when the content gets swapped out. However, when I try to include:

<%= container :some_container %>

i get the "undefined method `container' "

Help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant