开发者

jquery overlay close after submit a form with ajax

Hi I've tried everything, before asking you guys:

$(document).ready(function() {
var triggers = $("a[rel]").overlay({
    expose: {
        color: '#212121',
        loadSpeed: 200,
        opacity: 0.9
    },
    api: true,
    closeOnClick: true
});
});

$(document).ready(function(){

        $('#open_library').click(function (e) {     
            $('#OpenLib').slideToggle('slow');
            e.preventDefault();
            return false;
        });


    $forms = $('#library');
$forms.bind('submit', function(){
        var $button = $('button',this).attr('disabled',true);
        var params = $(this.elements).serialize();

        var self = this;
        $.ajax({
            type: 'POST',
            url: this.action,
            data: params,

        beforeSend: function(){
                $('#text_lib').show();

                $('#text_lib').html("Loading...");
            },
            success: function(txt){

                $button.attr('disa开发者_Python百科bled',false);

                $('#text_lib').html(txt);

                self.overlay().close();

                self.reset();
            },

            error: function(txt){
                $('#text_lib').html(txt);
            }
        })
        return false;
    });
});

<!--/* Begin PopLibrary*/-->
<div id="PopLib">
    <p style="color:#FFF; margin:0 0 30px 0">Add to Library</p>
    <form name="library" id="library" action="library_add.php">
        <select name="idlibrary" id="idlibrary" class="select_dropdown1" style="width:280px" title="Please select an library">
            <option value="0">Select one...</option>
                <?php
                if(isset($_COOKIE['cra_di']) AND $_COOKIE['cra_di'] != ''){
                    require_once("includes/php/user_info.php");
                    $library = $db->get_results("SELECT idlibrary, title FROM library WHERE user_id = $logged_user_id ORDER BY title ASC");
                    //echo print_r($library);
                    if($library) {
                        foreach($library as $k) {
                            echo '<option value="' . $k->idlibrary . '">' . $k->title . '</option>';
                        }
                    }
                }
                ?>
        </select>
        <div class="PopLibrary">
      <a href="#" class="grey_outter_link" id="open_library" style="font-size: 11px; text-decoration: underline;">Create new Library </a></div>
        <div id="OpenLib" style="display: none;">
            <label>Name</label>
            <input type="text" name="title" id="title" class="input_text required" maxlength="60" />
            <label>Comment</label>
            <textarea name="comment" style="margin: 5px 0 3px 0; height: 82px; width:218px" maxlength="336"></textarea><br />
            <input type="hidden" name="hidden_idproduct" id="hidden_idproduct" value="" />
            <input type="hidden" name="hidden_type" id="hidden_type" value="" />
        </div><!--/*OpenLib*/-->
        <div id="text_lib" style="margin-top:10px"></div>
      <div class="Inline" style="margin:30px 0 0 0"><input type="image" src="image/add_file_btn.gif" value="submit" /></div><div class="Inline" style="margin:30px 0 0 20px"><button type="button" class="close" style="">&nbsp;</button> </div><!--/*div*/-->
    </form>
    <div class=" clear"></div>
</div><!--/*PopLib*/-->
<!--/* End PopLibrary*/-->


Very simple.

self.overlay().close();

change to

$('#OpenLib').hide();

This is basic hiding.

If you using some plungin, then you shuld check out documentation of it. But i think triggers.close() will work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜