2017-02-17 33 views
-1

我有一個引導模式窗口,其中有一個引導列表組按鈕。在我的jquery/js中,當單擊某個按鈕時啓用提交按鈕,但如果在模式窗口中單擊其他位置,該按鈕將被取消選中!我如何查找此事件,以便禁用我的提交按鈕? 或者,如果我按下模式窗口上的其他位置,是否可以防止按鈕被取消選中?確定列表組項是否未被選中

這是我的模態窗口。

$(".removeReason").off('click').on('click', function() { 
 
    $("#removeMember").prop('disabled', false); 
 
}); 
 

 
// I need a .removeReason event that gets triggered when any button is unchecked
<div id="removeMemberModal" class="modal" tabindex="-1" role="dialog"> 
 
    <div class="modal-dialog" role="document"> 
 
    <div class="modal-content"> 
 
     <div class="modal-header"> 
 
     <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
 
     <h4 class="modal-title">@(ViewBag.IsTeacher == true ? "Remove Teacher" : "Remove Student")</h4> 
 
     </div> 
 
     <div class="modal-body"> 
 
     <p> 
 
      <h4>Why do you want to remove this @(ViewBag.IsTeacher == true ? "Teacher" : "Student")</h4> 
 
     </p> 
 
     <p> 
 
      <div class="list-group"> 
 
      <button type="button" class="list-group-item removeReason">Bad Reviews</button> 
 
      <button type="button" class="list-group-item removeReason">Made offensive comment</button> 
 
      <button type="button" class="list-group-item removeReason">Shows up late or misses class altogether</button> 
 
      <button type="button" class="list-group-item removeReason">Would like to register a different @(ViewBag.IsTeacher == true ? "Teacher" : "Student")</button> 
 
      <button type="button" class="list-group-item removeReason">Other</button> 
 
      </div> 
 
     </p> 
 
     <p> 
 
      @if(ViewBag.IsTeacher == true) { 
 
      <div>The teacher and all registered students will be notified by email that he/she has been removed from this event.</div> 
 
      } else { 
 
      <div>The student will be notified that he/she has been removed from this event.</div> 
 
      } 
 
     </p> 
 
     </div> 
 
     <div class="modal-footer"> 
 
     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
 
     <button id="removeMember" [email protected] type="button" class="btn btn-primary" disabled>Submit</button> 
 
     </div> 
 
    </div> 
 
    <!-- /.modal-content --> 
 
    </div> 
 
    <!-- /.modal-dialog --> 
 
</div> 
 
<!-- /.modal -->

回答

0

我通過將活性類每個被按壓的按鈕解決了這個。 像這樣

$(".removeReason").off('click').on('click', function() { 
 
    $(".removeReason").removeClass('active'); 
 
    $(this).addClass('active'); 
 
    $("#removeMember").prop('disabled', false); 
 
});

相關問題