Twitter bootstrap 3 引导模式将html加载到内容而不是正文中

Twitter bootstrap 3 引导模式将html加载到内容而不是正文中,twitter-bootstrap-3,Twitter Bootstrap 3,根据bootstrap 3.1.1中的源代码: if (this.options.remote) { this.$element .find('.modal-content') .load(this.options.remote, $.proxy(function () { this.$element.trigger('loaded.bs.modal') }, this)) } 从服务器加载的html片段

根据bootstrap 3.1.1中的源代码:

 if (this.options.remote) {
      this.$element
        .find('.modal-content')
        .load(this.options.remote, $.proxy(function () {
          this.$element.trigger('loaded.bs.modal')
        }, this))
    }
从服务器加载的html片段应该放在模式体中,而不是内容中

$('#myModal').modal({ remote: '@Url.Action("Create","Template")' });
加载的html放在整个对话框内容中,而不是正文中

我可以自己修改源代码

if (this.options.remote) {
      this.$element
        .find('.modal-body')
        .load(this.options.remote, $.proxy(function () {
          this.$element.trigger('loaded.bs.modal')
        }, this))
    }
但我不想修改引导源代码

<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
                ...
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


&时代;
...
接近
保存更改
这是部分html片段:

<script src="/Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>

<form action="/Template/Create" method="post">    <p class="editor-label"><label for="Name">Name</label></p>
    <p class="editor-field"><input class="text-box single-line" data-val="true" data-val-length="Name must not be longer than 30 chars." data-val-length-max="30" data-val-length-min="1" data-val-remote="This name already exists." data-val-remote-additionalfields="*.Name" data-val-remote-url="/Template/TemplateExists" data-val-required="Name must not be empty" id="Name" name="Name" type="text" value="" /></p>
    <p class="editor-field"><span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span></p> 
</form>

名称


我不明白你为什么这么咄咄逼人,但很明显,这并不愚蠢,因为boostrap就是这么告诉你的

你有两个选择1。你已经做了什么:

if (this.options.remote) {
  this.$element
    .find('.modal-body')
    .load(this.options.remote, $.proxy(function () {
      this.$element.trigger('loaded.bs.modal')
    }, this))
}
第二个选项,而不是插入此选项:

<form action="/Template/Create" method="post">    
    <p class="editor-label"><label for="Name">Name</label></p>
    <p class="editor-field"><input class="text-box single-line" data-val="true" data-val-length="Name must not be longer than 30 chars." data-val-length-max="30" data-val-length-min="1" data-val-remote="This name already exists." data-val-remote-additionalfields="*.Name" data-val-remote-url="/Template/TemplateExists" data-val-required="Name must not be empty" id="Name" name="Name" type="text" value="" /></p>
    <p class="editor-field"><span class="field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span></p>
</form>

名称

您只需插入这个(这就是bs脚本所期待的)


&时代;
接近
保存更改

希望有帮助

刚才也有同样的问题。我忘了包括一些引导js文件。如果有人会遇到同样的问题,以下是为我解决此问题的脚本:

<script type="text/javascript" src="bootstrap-modal/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="bootstrap-modal/js/bootstrap-modalmanager.js"></script>


您可以简单地加载所有内容,而不仅仅是body。这是Bootstrap v3.1.0中做出的明确的有意行为更改:
<script type="text/javascript" src="bootstrap-modal/js/bootstrap-modal.js"></script>
<script type="text/javascript" src="bootstrap-modal/js/bootstrap-modalmanager.js"></script>