我使用modal放置this form。为了做到这一点,我使用这个helper library:
BootstrapDialog.show({
message:formHtml
,cssClass:'.form-dialog'
});
我用这个css:
#ma-form-container{
width:600px;
height:100%;
}
#ma-form label
{
display:inline-block;
text-align:right;
}
我发现表单比模态大得多,我也尝试使用css:
#ma-form-container{
width:100%;
height:100%;
}
ÿ
当$("#ma-form")
打开时,我发现$("#ma-form-container")
和modal
为空。
我更改了模板并删除了插件:
<div id="openModal" style="display: block;"><div class="modal fade form-dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Details</h4>
</div>
<div class="modal-body">
<form class="form form-horizontal" role="form" id="ma-form">
<div class="form-group">
<span style="color:">
<label for="AUTHGRP" class="col-xs-3 control-label">AuthorizGroup</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="AUTHGRP" id="AUTHGRP" placeholder="AuthorizGroup">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="DESCRIPT" class="col-xs-3 control-label">Description</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="DESCRIPT" id="DESCRIPT" placeholder="Description">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="OBJECTTYPE" class="col-xs-3 control-label">Object type</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="OBJECTTYPE" id="OBJECTTYPE" placeholder="Object type">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="PLANGROUP" class="col-xs-3 control-label">Planner group</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="PLANGROUP" id="PLANGROUP" placeholder="Planner group">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="PLANPLANT" class="col-xs-3 control-label">Planning plant</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="PLANPLANT" id="PLANPLANT" placeholder="Planning plant">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="EQUICATGRY" class="col-xs-3 control-label">EquipCategory</label>
</span>
<div class="col-xs-6">
<input type="text" class="form-control" name="EQUICATGRY" id="EQUICATGRY" placeholder="EquipCategory">
</div>
</div>
<div class="form-group">
<span style="color:">
<label for="" class="col-xs-3 control-label"></label>
</span>
<div class="col-xs-6">
<input type="" class="form-control" name="" id="" placeholder="">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="formSubmit">Submit</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal --></div>
有了这个,我用它来打开对话框:
$("#map-actions a").on("click",function(e){
event.preventDefault();
$("#openModal").html(formHtml);
$("#openModal").css("display","block");
});
答案 0 :(得分:1)
在您的表单中,您使用了错误的语法来设置id属性
更改
id="#ma-form"
到
id="ma-form"
并且它会工作,不要忘记将这个递归地解决所有出现的错误
alert($('#ma-form').html())
将输出内容而不是&#34; undefined&#34;
欢呼声