开发者

SimpleModal Doesn't Close for me

开发者 https://www.devze.com 2023-02-22 16:37 出处:网络
Hello: I have several dialogs I intend to open using the rel attribute.I am missing something very basic, I know, but I just can\'t get it to close... (This system only allows me 2 \"a\" tags, so I li

Hello: I have several dialogs I intend to open using the rel attribute. I am missing something very basic, I know, but I just can't get it to close... (This system only allows me 2 "a" tags, so I linked with "alink"... it really is a, though)

Here is the 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>

Here are the links:

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

Here is the 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;
}

Here is the JQUERY (I'm in Wordpress no-conflict- $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

The issue is closing the "tool" Nothing happens when I click on the X... Again, I know it开发者_JAVA百科 must be simple, but I'm quickly running out of hair!!!

Thanks in advance! Brian


Try changing the this object in your click handler to a jQuery object:

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


Change:

$j(toshow).close();

To:

$j.modal.close();

Also, if you are manually adding close HTML, you can add the simplemodal-close class to have SimpleModal bind to it.

Change:

class="modalCloseImg"

To:

class="modalCloseImg simplemodal-close"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号