2011-04-07 65 views
0

你好: 我有几个对话框打算使用rel属性打开。我错过了一些非常基本的东西,我知道,但我不能让它关闭......(这个系统只允许我使用2个“a”标签,所以我用“alink”链接......它确实是一个,虽然)SimpleModal不会对我关闭

下面是HTML:

<div class="tool" id="first"> 
    <alink class="modalCloseImg" href="#"></alink> 
    First Content 
</div> 
<div class="tool" id="second"> 
    <link class="modalCloseImg" href="#"></link> 
    Second Content 
</div> 

这里是链接:

<div id="toolbox"> 
<ul> 
    <li><a href="#" rel="#first">First</a></li> 
    <li><a href="#" rel="#second">Second</a></li> 
</ul> 
</div><!-- toolbox --> 

这里是CSS:

.tool { 
/* initially overlay is hidden */ 
display:none; 
/* some padding to layout nested elements nicely */ 
padding: 10px 10px 65px 10px; 
/* a little styling */ 
font-size:11px; 
overflow: auto; 
background-color: #fff; 
border: 10px double black; 
height: 75%; 
min-width: 75%; 
width: auto; 
position: relative; 
} 

.tool a.modalCloseImg { 
background:url(images/x.png) no-repeat; 
width:25px; 
height:29px; 
display:inline; 
z-index:3200; 
position:absolute; 
top:0px; 
right:0px; 
cursor:pointer; 
border: 0; 
text-decoration: none; 
} 

^h ERE是jQuery的(我在WordPress的没有受冲突$ j)的

$j("#toolbox a[rel]").click(function(){ 
var toshow = this.rel; 
$j(toshow).modal({ 
    autoResize: false, 
    overlayClose:true, 
    containerCss: { 
     "background-color": "#aaa" 
    }, 
    overlayCss: { 
     "background-color": "#fff" 
    }, 
    onOpen: function (dialog) { 
     dialog.overlay.fadeIn('slow', function() { 
      dialog.data.hide(); 
      dialog.container.fadeIn('slow', function() { 
       dialog.data.slideDown('slow'); 
      }); 
     }); 
    }, 
    onClose: function (dialog) { 
     dialog.data.fadeOut('normal', function() { 
      dialog.container.slideUp('fast', function() { 
       dialog.overlay.fadeOut('fast', function() { 
        //Close the dialog. 
        $j(toshow).close(); 
       }); 
      }); 
     }); 
    } 


}); // jQuery object; this demo 

问题被关闭,当我点击X上的“工具”什么也没有发生。再次,我知道那一定是简单,但我很快就没了头发!

提前致谢! 布赖恩

+0

你粘贴,突出显示它并按下按钮的代码(它看起来像一对大括号{}) – Gazler 2011-04-07 19:25:21

回答

0

试着改变你的单击处理对象的jQuery对象:

var toshow = $(this).attr("rel"); 
0

变化:

$j(toshow).close(); 

要:

$j.modal.close(); 

而且,如果你可以手动添加关闭的HTML添加simplemodal-close类以使SimpleModal绑定它。

变化:

class="modalCloseImg" 

要:

class="modalCloseImg simplemodal-close"