我正在尝试为我的webapp实现一个简单的搜索和排序.我正在关注railscast和这个railscast.
我作为链接使用的可排序函数的应用程序帮助程序是:
def sortable(column, title = nil)
title ||= column.titleize
css_class = column == sort_column ? "current #{sort_direction}" : nil
direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc"
link_to title, params.merge(:sort => column, :direction => direction, :page => nil), {:class => css_class}
end
Run Code Online (Sandbox Code Playgroud)
我在视图中使用这些.在控制器中我使用白名单:
@listingssearch.where(:vehicletype => 'Car').order(sort_column + " " + sort_direction).paginate(:page => params[:page], :per_page => 30)
Run Code Online (Sandbox Code Playgroud)
私人消毒方法:
private
def sort_column
Listing.column_names.include?(params) ? params[:sort] : "rateperhour"
end
def sort_direction
%w[asc desc].include?(params[:direction]) …Run Code Online (Sandbox Code Playgroud) 我很难找到任何描述大型搜索表单的良好UI模式的资源.我有一个表格,需要20多个可能的输入,无法想出一个我感觉良好的设计(虽然在我的辩护中,我不是设计专家).在我的情况下,我正在寻找一个Web解决方案,但我想这个场景的UI模式可能与平台无关.
我看过像谷歌和亚马逊这样的网站(高级搜索),我想知道是否有更好的想法.有什么建议?
我想使用Backbone实现一个简单的搜索页面.它不是单页面应用程序,但仍希望使用Backbone构建我的JavaScript代码.搜索页面包含搜索表单和搜索结果.搜索是通过AJAX完成的,必须保存在历史记录中.从历史记录加载页面时,应将搜索查询参数加载到表单中.搜索表单和搜索结果可以实现为Backbone.View.但是,我在将它们粘合在一起时遇到了问题.
我认为我需要某种控制器.有一个Backbone.Router,但它是正确的地方吗?应该在哪里放置AJAX呼叫?
欢迎任何有关此页面结构的建议.
我想通过添加autocomplete="off"到搜索输入来稍微更改我的搜索表单.
我最初寻找一个简单的过滤器,如下所示:
//* Customize search form input box text
add_filter( 'genesis_search_text', 'sp_search_text' );
function sp_search_text( $text ) {
return esc_attr( 'Search my blog...' );
}
Run Code Online (Sandbox Code Playgroud)
但因为/genesis/lib/structure/search.php没有任何变量autocomplete="%s",所以该属性无法定位.我可能不得不直接介绍它,所以我将search.php父主题文件夹复制到子主题文件夹文件夹.
该文件的原始代码如下:
<?php
/**
* Replace the default search form with a Genesis-specific form.
*
* The exact output depends on whether the child theme supports HTML5 or not.
*
* Applies the `genesis_search_text`, `genesis_search_button_text`, `genesis_search_form_label` and
* `genesis_search_form` filters.
*
* @since 0.2.0
*
* @return …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的portlet创建一个搜索表单.portlet是一个地址簿应用程序,所有dao和服务构建器都使用服务构建器构建.我想给用户一个基本/高级搜索表单(就像liferay上的其他表格一样,例如控制中心的"用户和组织").
我已经实现了查看liferay源代码(6.1 GA1)的所有逻辑和页面,但搜索表单没有以任何方式显示,我将把代码放在这里.
在view.jsp中:
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("jspPage", "/html/addressbookportlet/view.jsp");
pageContext.setAttribute("portletURL", portletURL);
String portletURLString = portletURL.toString();
%>
<aui:form action="<%= portletURLString %>" method="get" name="fm">
<liferay-portlet:renderURLParams varImpl="portletURL" />
<aui:input name="isSearch" type="hidden" value="true" />
<aui:input name="redirect" type="hidden" value="<%= portletURLString %>" />
<liferay-ui:search-container
searchContainer="<%= new ABContactSearch(renderRequest, portletURL) %>"
>
<%
ABContactDisplayTerms displayTerms = (ABContactDisplayTerms)searchContainer.getDisplayTerms();
ABContactSearchTerms searchTerms = (ABContactSearchTerms)searchContainer.getSearchTerms();
Long societyId = GetterUtil.getLong(searchTerms.getSocietyId(),0);
Long contactTypeId = GetterUtil.getLong(searchTerms.getContactTypeId(), 0);
Long brandId = GetterUtil.getLong(searchTerms.getBrandId(),0);
Long channelId = GetterUtil.getLong(searchTerms.getChannelId(),0);
%>
<liferay-ui:search-form
searchContainer="<%=searchContainer%>"
servletContext="<%= this.getServletConfig().getServletContext() %>"
showAddButton="true"
page='<%= …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中实现了几个不同的搜索表单,试图实现一个特定的操作(输入对象ID并直接进入该实例的Show Page),并且我对此问题非常接近,直到遇到Unsupported: Symbol运行时错误for Cards#Index.
这是搜索表单(我把它放入layouts/application.html.erb:
<%= form_tag(cards_path, :method => "get") do %>
<div class="input-append">
<%= text_field_tag :search, params[:search], class: "span2", placeholder: "Search Cards" %>
<button class="btn" type="submit"><i class="icon-search"></i></button>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这是我的cards_controller.rb索引动作:
def index
if params[:search]
@cards = Card.search(params[:search]).order("created_at DESC")
else
@cards = Card.order("created_at DESC")
end
end
def show
end
private
def set_card
@card = Card.find(params[:id])
end
def card_params
params.require(:card).permit(:title, :description)
end
Run Code Online (Sandbox Code Playgroud)
和模型 card.rb
class Card < ActiveRecord::Base
validates :title, presence: true, uniqueness: …Run Code Online (Sandbox Code Playgroud) search-form ×6
backbone.js ×1
genesis ×1
liferay ×1
parameters ×1
php ×1
ruby ×1
sorting ×1
wordpress ×1