2016-09-12 3 views
-1

Ich versuche das Bootstrap-Framework, insbesondere, dass Jquery Modal-Bildschirm zeigt, aber es funktioniert nicht.Bootstrap - Test 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> 

Der Code ist sehr einfach, verstehe ich nicht, warum es nicht :(

funktioniert Ist es möglich, das Problem der Datei enthalten die jquery ist oder ich weiß es nicht.

Grüße,

+2

Was sagt die Konsole? und wo schließt Bootstrap ein? – depperm

+0

Bitte sehen Sie sich diese [http://getbootstrap.com/javascript/#modals] Beispiele an. Du verpasst mehr als die Hälfte des notwendigen Codes, damit die Mods funktionieren. Einschließlich Bootstrap selbst und der HTML-Container. – empiric

+0

Danke für Ihre Antworten. Ich werde die Beispiele sehen. – ruzD

Antwort

1

umfassen:

<!-- 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> 

In der Kopfzeile - Sie haben Stiefel nicht wirklich hinzugefügt falle in dein Dokument ein.

bewegen sich auch

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

Um die Kopfzeile über alle diese drei Verbindungen. Dies sollte zuerst geladen werden, um in Bootstrap verwendet zu werden.

Wenn Sie alle diese kopieren:

<!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> 

In deine .html Datei, wird es funktionieren.

+0

Vielen Dank! Schon sehe ich das Problem, das beinhaltet! – ruzD