我想创建一个Navbar按钮,调用包含表单的bootstrap模式。我在https://gist.github.com/havvg/3226804找到了一个要点,我正在努力使其适应我的需要。我还没有填写脚本的ajax部分,但我注意到模态没有激活。我想按导航栏上的按钮并弹出模态窗体。我做错了什么?
<div class="hide fade modal" id="rating-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">button</button>
<h2>Your Review</h2>
</div>
<div class="modal-body">
<!-- The async form to send and replace the modals content with its response -->
<form class="form-horizontal well" id="modalForm" data-async data-target="#rating-modal" action="AjaxUpdate/modal" method="POST">
<fieldset>
<!-- Form Name -->
<legend>modalForm</legend <!-- Text input-->
<div class="control-group">
<label class="control-label" for="old">Old password</label>
<div class="controls">
<input id="old" name="old" type="text" placeholder="placeholder" class="input-xlarge">
<p class="help-block">help</p>
</div>
</div>
<!-- Text input-->
<div class="control-group">
<label class="control-label" for="new">New password</label>
<div class="controls">
<input id="new" name="new" type="text" placeholder="placeholder" class="input-xlarge">
<p class="help-block">help</p>
</div>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer"> <a href="#" class="btn" data-dismiss="modal">Cancel</a>
</div>
</div>
<script src='js/jquery.js'></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
// $('form[data-async]').live('submit', function(event) {
$('#modalForm').on('submit', function (event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
success: function (data, status) {
$target.html(data);
}
});
event.preventDefault();
});
});
</script>
答案 0 :(得分:0)
尝试从div中删除课程hide
:
<div class="fade modal" id="rating-modal">