<div class="row">
<form class="comment-form" method="post" action="{% url 'articles:reply' %}">
{% csrf_token %}
{{ form.comment }}
<input type="hidden" name="article_id" id="article_id" value={{ article.pk }}>
<button class="btn btn-primary pull-right" style="margin-top: 3px" type="submit">提交评论</button>
</form>
</div>
<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">
×
</button>
<h4 class="modal-title" id="myModalLabel">
</h4>
</div>
<div class="modal-body">
<form class="comment-form" method="post" action="{% url 'articles:reply' %}">
{% csrf_token %}
{{ form.comment }}
<input type="hidden" name="article_id" id="article_id" value={{ article.pk }}>
<input type="hidden" name="reply_id" id="reply_id" value="">
<button class="btn btn-primary pull-right" style="margin-top: 3px" type="submit">提交评论</button>
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
1
liulibzz OP 用了这个也没起作用,不会 JS 头大昂
$.fn.modal.Constructor.prototype.enforceFocus = function() { modal_this = this $(document).on('focusin.modal', function (e) { if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_textarea') && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) { modal_this.$element.focus() } }) }; |