Jquery覆盖关闭后提交一个表单与ajax



嗨,在问你们之前,我什么都试过了:

$(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('disabled',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*/-->

非常简单。

self.overlay().close();

改变

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

这是基本隐藏。

如果你使用了一些插件,那么你应该查看它的文档。但我认为triggers.close()将工作

最新更新