分叉弹性网格插件,使其能够通过单击屏幕上的任意位置来关闭预览 [英] Forking elastic grid plugin to be able to close preview by clicking anywhere on the screen
问题描述
我正在将弹性网格插件用于站点上的网格显示系统,但是我希望能够简单地单击展开的视图,并且该视图自动关闭,而无需单击缩略图或"x"按钮,插件提示.
I'm using the elastic grid plugin for a grid display system on a site, but I want to be able to simply click off the expanded view and it automatically close without having to click on the thumbnail or 'x' button as the plugin suggests.
我已经看过一些代码,认为这是我需要编辑的地方
I've had a bit of a look through the code and think this is where I need to edit
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;
});
However, I'm not sure exactly how to do this. I was trying to implement this method mentioned here but am having no luck. Any guidance in this would be appreciated.
供参考的插件: http://demo.phapsu.com/jquery.elastic_grid/
推荐答案
如果您尚未找到答案,请将其添加到js页面中,如果您单击页面中除扩展名以外的任何位置,它将关闭扩展名视图自己查看.
if you haven't found an answer yet, add this your js page, it will close the expanded view if you click any where in the page except the expanded view it self.
$('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");
});
这篇关于分叉弹性网格插件,使其能够通过单击屏幕上的任意位置来关闭预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!