Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:43:03+00:00 2026-06-11T14:43:03+00:00

Am trying to do ajax pagination without using any pagination gems for menus (which

  • 0

Am trying to do ajax pagination without using any pagination gems for menus (which is like template). For example to display brand menu on mouse hover of the brand menu name am using “menu_brand” render because when page loads at that time only am getting brands from the database. for this rendered view I have to do pagination function. Am successfully getting the current page contents in the console log.

In controller am doing like this

def menu_brand
    $cnt=Brand.count
end

def menu_brand_page
    $st=0
    if !(params[:startingRow].nil?)
        $st = params[:startingRow].to_i
    end
    $brands=Brand.limit(24).offset($st)
end

In _menu_brand.html.erb

<% if !($cnt.nil?) %>
<% @pg = ($cnt / 24).ceil %>

<div class="paginator">
    <%
    for j in 0..@pg %>
    <%= link_to "#{j+1}", "javascript:GotoPage('#{j*24}')",  %>
    <% end
    %>
</div>
<table width="700px"; align="center" id="menupage">
    <%= render "menu_brand_page"%>
</table>
<% end %>
<script type="text/javascript">
    function GotoPage(startrow) {
var theURL = '/menu_brand_page/'+<%= params[:deptid] %>
    +'/' + startrow;
    $.ajax({
        url : theURL
    });
    }
</script>

In menu_brand.js.erb

$('#bval').html('<%= escape_javascript render ('menu_brand') %>');

In _menu_brand_page.html.erb

<% $brands.each do |brand| %>
    <%= brand.name %>
<% end %>

In menu_brand_page.js.erb

$('#menupage').html('<%= escape_javascript render ('menu_brand_page') %>');

In layout

<div id="bval">
<%= render "menu_brand" %>
</div>
<script type="text/javascript">
$(document).ready(function() {
var theBrand = '/menu_brand/' + <%= params[:deptid] %>;
$.ajax({
url : theBrand
});
});
</script>

My router.rb

match "menu_brand_page/:deptid/:startingRow" => "product_details#menu_brand_page"
match "menu_brand/:deptid" => 'product_details#menu_brand'

console log output

$(‘#menupage’).html(‘\n\n \nBC\n</td>\n\n \nBC Footwear\n</td>\n\n \nBCBG\n</td>\n</tr>\n\n\n \nBCBGeneration\n</td>\n\n \nBCBGMAXAZRIA\n</td>\n\n \nBCX\n</td>\n</tr>\n\n\n \nBe Creative\n</td>\n\n \nBeach Bunny\n</td>\n\n \nBeach House\n</td>\n</tr>\n\n\n \nBeach House Woman\n</td>\n\n \nbebe\n</td>\n\n \nBecca\n</td>\n</tr>\n\n\n \nBed Stu\n</td>\n\n \nBellatrix\n</td>\n\n \nBELLE BY SIGERSON MORRISON\n</td>\n</tr>\n\n\n \nBelle Du Jour\n</td>\n\n \nBelle Noel\n</td>\n\n \nBen Amun\n</td>\n</tr>\n\n\n \nBENCH\n</td>\n\n \nBerek\n</td>\n\n \nBernardo\n</td>\n</tr>\n\n\n \nBERNIE OF NEW YORK\n</td>\n\n \nBETMAR\n</td>\n\n \nBetsey Johnson\n</td>\n</tr>\n\n’);

Please help me am not getting why contents are not changing in menu_brand view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:43:05+00:00Added an answer on June 11, 2026 at 2:43 pm

    Thank you @agncleod. @agmcleod is right. I was calling render at document ready function and I have used the global variables a lot. Now am rendering on mouse hover event and am using instance variable. I corrected this mistake. I have changed all my global ($) variables to instance (@) variable. In layout am calling render function as I mentioned below.

    In Layout

    <a href="#" id="menubrand">brands</a>
    <div id="bval">
    <%= render "menu_brand" %>
    </div>
    <script type="text/javascript">
    $("a#menubrand").hover(function () {
    var theBrand = '/menu_brand/' + <%= params[:deptid] %>;
    $.ajax({
    url : theBrand
    });
    },
    function () {
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to intercept ajax requests with jquery, to display a waiting message like
I'm trying to set up a relatively simple AJAX pagination with jQuery like this:
I am trying to make my Ajax-enabled table pagination 508-compliant (accessible using JAWS version
I'm using magento as my CMS, trying to implement ajax for pagination, I have
I am trying AJAX for the first time on my localhost. I am using
I am trying to create a jquery plugin to do ajax table pagination (i.e
In my rails application I am trying to access pagination via an ajax call.
I'm trying to AJAX-ify the Django contact_form app using Django (1.4.2). I want to
Currently Im trying to do ajax request using jQuery Mobile. I`m trying to use
I am trying to create ajax pagination on Blog Page.. What I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.