renderFilterOn: html
|aFilter|
html textInput
onKeyUp: (html jQuery ajax callback: [:val | aFilter := val]
value: ((html jQuery this) value);
script: [:s |
s add: ((s jQuery class: 'itemnames')
each: (s jQuery ajax callback: [:v | |aName anID |
aName := ((v subStrings: $,) last).
anID := ((v subStrings: $,) first).
((aName asUppercase) includesSubString: (aFilter asUppercase))
ifFalse: ["Do something here to hide values"]] value: (Array with: ((html jQuery this) attributeAt: 'id') with: (html jQuery this) text)))
]
)
那么,在“在这里做一些事情来隐藏值”中我该怎么做?
我获得的 ID 是我想要隐藏其父“tr”元素的“td”元素的 ID。
我真的不想做新组件并渲染东西,因为表格可以包含数千个结果,并且显示一个新组件,并在每次按键时过滤这些结果会使事情变得太慢。
最佳答案
如果您关心速度并且在初始渲染期间已经将所有数据发送到客户端,那么您应该在客户端上使用 JS 进行所有过滤。
我会创建一个这样的 CSS 类:
.hideRow {
display:none;
}
并根据输入中键入的内容向行添加或删除该类。
将输入渲染方法更改为:
renderFilterOn:html
html textInput
id: html nextId;
onKeyUp:((html jQuery id: html lastId) call:'filterRows').
然后向该页面提供一个静态 js 文件,其中包含 filterRows 函数,该函数根据输入的值添加或删除类
关于jquery - Smalltalk Seaside 键入时进行 jQuery 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17209024/