我有一個模式彈出更改密碼,我需要關閉它的提交按鈕。如何在表單提交中關閉模式彈出窗口?
<div class="modal-body">
<?php if(isset($message))echo '<span class="text-success txt-upper" style="margin-left:2rem;">'. $message .'</span>';?>
<?php echo form_open('',array('class'=>'ajaxForm')); ?>
<fieldset class="table ">
<div class="form-group">
<?php $class = form_error('newpassword')?"input-error":"" ?>
<div class="col-md-12" style="margin: 10px 0"><?php echo form_password('newpassword','','class="form-control margin-both-0 '. $class.'" id="newpassword" placeholder="New Password" autocomplete="off"'); ?><?php echo form_error('newpassword'); ?></div>
</div>
<div class="form-group">
<?php $class = form_error('conpassword')?"input-error":"" ?>
<div class="col-md-12 " style="margin: 10px 0"><?php echo form_password('conpassword','','class="form-control margin-both-0 '. $class.'" id="conpassword" placeholder="Confirm Password" autocomplete="off"'); ?><?php echo form_error('conpassword'); ?></div>
</div>
</div>
<div class="modal-footer">
<?php echo form_submit('submit_btn', 'Change Password', 'class="submit btn btn-success margin-left-4p pad-1-rem margin-bottom-10"'); ?>
</fieldset>
<?php echo form_close();?>
</div>
上面的代碼是表單提交按鈕。
$(function() {
$(".submit").click(function(e){
var sdata = $('.ajaxForm').serialize();
$.ajax({
type: "POST",
data:sdata,
url: "<?php echo site_url('home/change_password'); ?>",
success: function(data){
$('#baseModal-xs .modal-content').html(data);
}
});
return false;
});
});
<script type="text/javascript">
$(".submit").ajaxForm(function() {
window.close();
});
這是JavaScript我已經添加了windows.close功能無法正常工作
是否使用bootstrap3?如果是這樣,$('。modal')。modal('hide'); – ItayB
嘗試從父窗口關閉它。 – anmarti
@anmarti我該怎麼做? –