JQuery 移动搜索输入图标
我想知道使这个放大镜图标成为可点击按钮的最佳方法是什么? 无需更改 JQuery 框架
http://jquerymobile.com/demos/ 1.0a2/#docs/forms/forms-search.html
这是它在框架中映射的位置
if( input.is('[type="search"],[data-type="search"]')
focusedEl = input.wrap('<div class="ui-input-search ui-shadow-inset ui-btn-corner-all ui-btn-shadow ui-icon-search'+ themeclass +'"></div>').parent();
I was wondering whats the best way to make this magnifying glass Icon in to clickable button?
without changing the JQuery framework
http://jquerymobile.com/demos/1.0a2/#docs/forms/forms-search.html
This is where it's mapped in the framework
if( input.is('[type="search"],[data-type="search"]')
focusedEl = input.wrap('<div class="ui-input-search ui-shadow-inset ui-btn-corner-all ui-btn-shadow ui-icon-search'+ themeclass +'"></div>').parent();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 javascript hack 做任何事情都会破坏整个渐进增强想法。
只需创建一个普通的提交按钮并用
包裹它,然后在最后使用
!important
创建一些 CSS 规则来覆盖jqm 创建的元素的 jQuery Mobile 按钮样式用于替换提交按钮(使用 firebug 检查它以掌握其中创建的内容)最后 - 如果你想让 tit 在支持一半的浏览器中看起来不错,你将必须获得其中一个并添加另一个 CSS 规则。
完毕。有一个针对不支持的浏览器的按钮,它通过 CSS 增强为放大镜。无处不在。
Doing anything with a javascript hack will destroy the whole progressive enhancement idea.
Just create a normal submit button and wrap it with a
<span class="maglass">
and then just crete some CSS rules with!important
at the end to overwrite the jQuery Mobile button styles for the elements jqm creates to replace the submit button (inspect it with firebug to get the grip of what is created there)And finally - if you want tit to look good in half-supported browsers you will have to get one of these and add yet another CSS rule.
Done. There's the button for not supported browsers and it enhances to a magnifying glass with CSS. Works everywhere.
我能说的最好的就是它是一个带有输入元素的 div 主题。话虽这么说,您可能可以执行以下两件事之一:
绑定到输入的包装器,例如:
或者,您朝另一个方向走:
仅取决于您想要走的方向。 (并且可能应该使用 jquerymobile 事件,而不是经典的 jQuery 事件(这样你就可以捕获Figner Taps等))此外,这应该被解释为伪代码,因为我不熟悉图书馆,只是用我所知道的。
编辑
很明显,我意识到需要对 DIV 的点击事件做更多的事情(在检查方面)。您需要测试实际在 DIV 上执行的单击,而不是导致 DIV 事件触发的输入。
只是把它扔在那里以避免“这不起作用”的评论。这就是为什么它是伪代码。
The best I can tell it's a div themed with an input element. That being said, you can probably do one of two things:
Bind to the input's wrapper such as:
OR, you go the other direction:
Just depends the direction you want to go. (And probably should be using the jquerymobile events, not classic jQuery ones (so you can catch figner taps, etc.)) Also, this should be interpreted as pseudo-code as I am not familiar with the library, just going with what I know.
EDIT
And so it's clear, I realize more has to be done (in terms of checking) for the DIV's click event. You would need to test the click was actually performed on the DIV not the input which results in a DIV event fire.
Just throwing it out there to avoid "this doesn't work" comments. This is why it's pseudo-code.