Rails将滤镜应用于视图 [英] Rails Applying Filters to views

查看:79
本文介绍了Rails将滤镜应用于视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在rails中创建过滤器的最佳方法是什么.所以基本上我有一个带有行和列的html表,其中列出了很多信息.现在我想按日期,名称,升序,降序等对该表进行排序...

What is the best way in rails to create a filter. So basically I have a html table with rows and columns which lists a lot of information. Now I want to sort that table by date, by name, ascending, descending, etc...

我不希望使用javascript来完成此操作,如果可能的话,我宁愿使用ruby代码.实现此目标的最佳方法是什么?如果那不是解决问题的好方法,那么我不必使用表.同样通过使用代码,这是否意味着每次我希望应用过滤器时,我都必须刷新页面,或者无需刷新页面就可以做到这一点,它可以即时吗?

I do not wish to use javascript to accomplish this, if possible I would rather it used ruby code. What would be the best way to achieve this? I do not have to use a table if that is not a good way to go about it. Also by using code does that means that every time I wish to apply a filter I would have to refresh the page or can it be done without having to refresh the page, can it be instant?

推荐答案

以下是有关您正在寻找的内容的精彩广播: http://railscasts.com/episodes/240-search-sort-paginate -with-ajax

The following is a great railcast about exactly what you're looking for: http://railscasts.com/episodes/240-search-sort-paginate-with-ajax

它向您显示使用和不使用JavaScript.

It shows you both with and without javascript.

如果您想在不刷新页面的情况下应用过滤器,则意味着您需要使用Javascript.

If you want to apply a filter without refreshing the page, it means you need to use Javascript.

这篇关于Rails将滤镜应用于视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆