DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> Bootstrap彈出框modal上層的輸入框不能獲得焦點問題的解決方法
Bootstrap彈出框modal上層的輸入框不能獲得焦點問題的解決方法
編輯:關於JavaScript     

Bootstrap 彈出框modal上層的輸入框不能獲得焦點問題,具體內容如下

1.在使用Bootstrap框架中目前modal彈出框只支持一層

即在當前彈出框上不能再使用modal彈出框。
如果使用自定義的彈出框,例如:http://my.oschina.net/tianma3798/blog/737232
如果自定義彈出框中有input輸入框,如果input 輸入框不能獲得焦點,則可能原因如下:
許多使用定義彈出層

<div class="modal fade" tabindex="0" role="dialog" id="myModal" data-backdrop="static"> 
 <div class="modal-dialog modal-lg"> 
  <div class="modal-content"> 
  <div class="modal-header"> 
   <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> 
   <h4 class="modal-title" id="myModalLabel">添加學校</h4> 
  </div> 
  <div class="modal-body"> 
   <form class="form-horizontal" name="myForm" novalidate> 
   <input type="hidden" ng-model="entity.SchID" /> 
   <div class="form-group"> 
    <label for="SchName" class="col-sm-2 control-label">學校名稱:</label> 
    <div class="col-sm-10"> 
    <input type="text" required ng-minlength="3" ng-maxlength="30" 
     class="form-control" 
     ng-model="entity.SchName" name="SchName" placeholder="長度3-30"> 
    <span class="text-danger" ng-show="myForm.SchName.$dirty && myForm.SchName.$invalid"> 
     <span ng-show="myForm.SchName.$error.required">名稱是必須的</span> 
     <span ng-show="myForm.SchName.$error.minlength">最小長度3</span> 
     <span ng-show="myForm.SchName.$error.maxlength">最大長度30</span> 
    </span> 
    </div> 
   </div> 
 
   <div class="form-group"> 
    <label for="WebSite" class="col-sm-2 control-label">學校官網:</label> 
    <div class="col-sm-10"> 
    <input required type="url" class="form-control" ng-model="entity.WebSite" name="WebSite" 
     placeholder="鏈接地址" /> 
    <span class="text-danger" ng-show="myForm.WebSite.$dirty && myForm.WebSite.$invalid"> 
     <span ng-show="myForm.WebSite.$error.required">姓名是必須的</span> 
     <span ng-show="myForm.WebSite.$error.url">鏈接格式不正確</span> 
    </span> 
    </div> 
   </div> 
 
   <div class="form-group"> 
    <label for="FoundTime" class="col-sm-2 control-label">建校時間:</label> 
    <div class="col-sm-10"> 
    <input required type="number" class="form-control" ng-model="entity.FoundTime" name="FoundTime" 
     placeholder="年份" /> 
    <span class="text-danger" ng-show="myForm.FoundTime.$dirty && myForm.FoundTime.$invalid"> 
     <span ng-show="myForm.Summary.$error.required">姓名是必須的</span> 
     <span ng-show="myForm.Summary.$error.number">請輸入數字(年份)</span> 
    </span> 
    </div> 
   </div> 
   <div class="form-group"> 
    <label class="col-sm-2 control-label">入學時間:</label> 
    <div class="col-sm-10"> 
    <div class="selectBox" id="selectMonth"></div> 
    <input type="hidden" name="Province" ng-model="entity.MonthList" /> 
    </div> 
   </div> 
   </form> 
  </div> 
  <div class="modal-footer"> 
   <button type="button" class="btn btn-success" ng-disabled="myForm.$invalid" ng-click="addOrUpdate()">保存</button> 
   <button type="button" class="btn btn-default" data-dismiss="modal">關閉</button> 
  </div> 
  </div> 
 </div> 
 </div> 

解決方式是去掉 tabindex="0" 屬性,然後就可以獲得焦點了

<div class="modal fade" role="dialog" id="myModal" data-backdrop="static"> 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved