2015-05-04 13 views
0

使用AJAX加載Kaminari分頁表。 分頁本身也使用AJAX。如何配置Kaminari分頁的URL? '.json'自動添加

在我的控制器:

def update_user_list 
    modal = render_to_string('tables/_user_table', :layout => false, :formats=>[:html]).html_safe 
    data = { 
    :table => modal 
    } 
    respond_to do |format| 
    format.json { render :json => data } 
    end 
end 

在表/ _user_table

# Table part and content notrelated 
<%= paginate @users, :params => {:controller => 'product', :action => 'more_users'}, :remote => true, :theme => 'twitter-bootstrap-3' %> 

響應update_user_list的JSON的樣子:

{ 
    table=" // the table part 
      // the pagination part shows as follows 
      <li class="page"><a href="/product/more_users.json?page=3&amp;user_subgroup_id=1" data-remote="true">3</a></li> 
      <li class="page"><a href="/product/more_users.json?page=4&amp;user_subgroup_id=1" data-remote="true">4</a> 
     " 
} 

我要的是刪除」以.json 「在網址中。

如果我只是渲染沒有AJAX的tables/_user_table,而不是在JSON對象中,它在url中沒有「.json」。

版本: 導軌:3.2.17 雷:0.13.0 引導-雷的觀點:0.0.3

回答

0

發現問題。它實際上不包括在問題中。

$.ajax({ 
    url: '<%= user_product_index_url %>.json', 
    success: function(data) { 
     // not important...... 
    }); 

刪除 「以.json」 在這裏解決問題...