2016-09-12 5 views
-1

Я пробовал фреймворк bootstrap, в частности, что jquery показывает модальный экран, но он не работает.Bootstrap - тестовый jquery modal

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 

<title>AddCloud - Edicions</title> 
</head> 

<body> 
     <div class="modal-body"> 
      <table id="table_search" class="table table-hover"> 
       <thead> 
        <tr> 
         <td>CCA</td> 
         <td>Name</td> 
        </tr> 
       </thead> 
       <tbody> 
        <tr> 
         <td>1</td> 
         <td>2</td> 
         <td>3</td> 
        </tr> 
        <tr> 
         <td>a</td> 
         <td>b</td> 
         <td>c</td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 

     <script> 
      $('#table_search > tbody').on('click', '>tr', function() { 
       alert($(this).text()); 
      }); 


      $('#table_search > tbody > tr').dblclick(function() { 
       alert($(this).text()); 
      }); 
     </script> 

     <script src="assets/jquery/jquery.min.js"></script> 
</body> 
</html> 

код очень легко, я не понимаю, почему он не работает :(

Возможно ли проблема файл содержит JQuery или я не знаю.

С уважением,

+2

Что говорит консоль? и где вы включаете загрузку? – depperm

+0

Пожалуйста, посмотрите примеры [этих] (http://getbootstrap.com/javascript/#modals). Вам не хватает более половины необходимого кода для работы модалов. Включая сам bootstrap и контейнер html. – empiric

+0

Спасибо за ваши ответы. Я увижу примеры. – ruzD

ответ

1

включают:

<!-- Latest compiled and minified CSS --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 

<!-- Optional theme --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 

<!-- Latest compiled and minified JavaScript --> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 

В вашем заголовке - вы на самом деле не добавил сапоги ловушку в ваш документ.

двигаться Также

<script src="assets/jquery/jquery.min.js"></script> 

К вашему заголовку выше всех этих трех звеньев. Сначала это должно быть загружено для загрузки в Bootstrap.

Если вы копируете все это:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.js"></script> 

<!-- Latest compiled and minified CSS --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 

<!-- Optional theme --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 

<!-- Latest compiled and minified JavaScript --> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 

<title>AddCloud - Edicions</title> 
</head> 

<body> 
    <div class="container"> 

    <!-- Button trigger modal --> 
    <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> 
     Launch demo modal 
    </button> 

    <!-- Modal --> 
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
     <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" id="myModalLabel">Modal title</h4> 
      </div> 

      <div class="modal-body"> 
       <table id="table_search" class="table table-hover"> 
        <thead> 
         <tr> 
          <td>CCA</td> 
          <td>Name</td> 
         </tr> 
        </thead> 
        <tbody> 
         <tr> 
          <td>1</td> 
          <td>2</td> 
          <td>3</td> 
         </tr> 
         <tr> 
          <td>a</td> 
          <td>b</td> 
          <td>c</td> 
         </tr> 


     </tbody> 
      </table> 
     </div> 

     <div class="modal-footer"> 
     <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 

    </div> 
    </div> 
</div> 

<script> 
    $('#table_search > tbody').on('click', '>tr', function() { 
     alert($(this).text()); 
    }); 


    $('#table_search > tbody > tr').dblclick(function() { 
     alert($(this).text()); 
    }); 
</script> 

В файле .html, он будет работать.

+0

Большое спасибо! Я уже вижу проблему, включая! – ruzD