JavaScript - Lightview Modal保持关闭

时间:2011-02-22 20:47:32

标签: javascript prototypejs modal-dialog

我的lightview模式在Ajax请求后继续关闭。这意味着当我发出一个Ajax请求之后我打电话给lighview弹出窗口时,弹出窗口会在加载弹出页面后立即关闭。如果我没有发出Ajax请求,弹出窗口工作正常,除非用户完成,否则不会关闭。

任何人都可以帮我解决我做错的事吗?下面是模拟我的问题的代码。

<script language="JavaScript" type="text/javascript">
Event.observe(
    window,
    'load',
    function ( event ) {
        $( 'ajaxBtn' ).observe(
            'click',
            function( event ) {
                ajaxCall( 'ajax.png' );
            });
    });

function ajaxCall( img_url )
{
    Lightview.show({ href: img_url, rel: 'image', options: { width: 100, height: 100, autosize: false, keyboard: true, overlayClose: false, menubar: false } });

    document.observe("lightview:opened", function(event)
    {
        new Ajax.Request(
            'ajax_post.html',
            {
                method: 'POST',
                parameters: $('frmName').serialize( true ),
                onComplete: ajaxSuccess,
                onFailure: ajaxFailed
            });
    });
}

function ajaxSuccess( )
{
    Lightview.hide();
    alert("Ajax call success");
}

function ajaxFailed()
{
    Lightview.hide();
    alert("Ajax call failed");
}
</script>

<form accept-charset="utf-8" name="frmName" id="frmName" method="post">
    Name: <input type="text" name="full_name" id="full_name" value="" />
    <input type="hidden" name="id" id="id" value="1" /><br />

    <img id="ajaxBtn" src="ajaxBtn.jpg" style="cursor: pointer;" title="Ajax Call" alt="Ajax Call" border="0" />

    <a href="pop-up.html" class="lightview" title="pop-up :: :: topclose: true, width: 600, height: 180">pop-up window</a>
</form>

先谢谢。

1 个答案:

答案 0 :(得分:1)

ajaxSuccess()ajaxFailed()函数调用Lightview.hide()上,我认为这是原因。
您是否尝试删除Lightview.hide()