分叉弹性网格插件,能够通过单击屏幕上的任意位置来关闭预览
Forking elastic grid plugin to be able to close preview by clicking anywhere on the screen
我正在将弹性网格插件用于网站上的网格显示系统,但我希望能够简单地单击展开的视图,它会自动关闭,而无需单击缩略图或插件建议的"x"按钮。
我已经浏览了一下代码,并认为这是我需要编辑的地方
function initEvents() {
//when clicking an item, show the preview with the items info and larg image;
//close the item if already expanded.
//also close if clicking on the item's cross
$items.on( 'click', function(e) {
hidePreview();
return false;
} ).children( 'a' ).on( 'click', function(e) {
var $item = $( this ).parent();
//check if item already opened
current === $item.index() ? hidePreview() : showPreview( $item );
return false;
});
但是,我不确定如何做到这一点。我试图实现这里提到的这种方法,但没有运气。如能提供这方面的任何指导,将不胜感激。
供参考的插件:http://demo.phapsu.com/jquery.elastic_grid/
如果您
还没有找到答案,请将其添加到您的 js 页面,如果您单击页面中除展开视图之外的任何位置,它将关闭展开的视图。
$('body').click(function(evt){
if(evt.target.class== "og-expander")
return;
// For descendants of menu_content being clicked, remove this
// check if you do not want to put constraint on descendants.
if($(evt.target).closest('.og-expander').length)
return;
$(".og-close").trigger("click");
});
相关文章:
- 一个html/javascript'小工具'知道用户何时单击了小部件外的任意位置
- 单击任意位置如何关闭框
- 单击任意位置关闭菜单
- Angularjs-将指令中的值绑定到文档中的任意位置显示/隐藏
- 单击页面上的任意位置时隐藏两个元素
- 匹配字符串中任意位置的 3 个字符的正则表达式
- 当用户单击网页中的任意位置时,如何获得通知
- 分叉弹性网格插件,能够通过单击屏幕上的任意位置来关闭预览
- 如何通过单击页面上的任意位置关闭下拉列表
- 通过单击任意位置关闭 JavaScript 弹出窗口
- 当用户单击文档中的任意位置时淡化弹出窗口
- 将类添加到动态元素上的正文,在页面上的任意位置再次单击后删除
- 当用户单击该弹出窗口图面之外的页面上的任意位置时,如何关闭动态添加的弹出窗口
- 如何使输入组在完成写入后或单击任意位置时折叠
- JQuery:单击 #element 以外的任意位置
- 元素在页面上的任意位置按键时隐藏
- 如何通过单击任意位置关闭javascript下拉菜单
- 通过单击弹出窗口外部的任意位置来关闭弹出窗口
- 在模态之外的任意位置单击时关闭模态窗口
- 单击任意位置链接