引导程序是否干扰了我的Jqueryui或者我错过了什么?

时间:2017-09-21 08:14:31

标签: javascript jquery css twitter-bootstrap jquery-ui

尝试将Jqueryui Sortable交互放入Bootstrap表中,以便人们可以移动行来比较它们。

Jqueryui与Bootstrap不兼容吗?我可以不将表行放在列表中吗?喜欢这里的问题是什么?我不理解这个问题,因为没有一行可以排序/移动。

HTML和JS-

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="./Bombers Hockey_files/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="./Bombers Hockey_files/bootstrap.min.js.download" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<link href="./Bombers Hockey_files/hockey.css" rel="stylesheet" type="text/css">
<script src="./Bombers Hockey_files/jquery.min.js.download"></script>
<script src="./Bombers Hockey_files/popper.min.js.download"></script>

      <script>
      $( function() {
        $( "#sortable" ).sortable();
        $( "#sortable" ).disableSelection();
      } );
      </script>

    <table class="table table-hover table-striped">
            <thead>
      <tr>
        <th>Name</th>
        <th>GP</th> 
        <th>Goals</th>
        <th>Assists</th>
        <th>Points</th>
        <th>Penalties</th>
      </tr>
    </thead>
      <tbody>
    <ul id="sortable">
    <li class="ui-state-default">
        <tr>
        <td>Adam</td>
        <td>12</td> 
        <td>2</td>
        <td>0</td>
        <td>2</td>
        <td>2</td>
      </tr>
    </li>
    <li class="ui-state-default">
      <tr>
        <td>Braden</td>
        <td>8</td> 
        <td>0</td>
        <td>1</td>
        <td>1</td>
        <td>2</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Caleb</td>
        <td>10</td> 
        <td>2</td>
        <td>1</td>
        <td>3</td>
        <td>6</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>John</td>
        <td>8</td> 
        <td>2</td>
        <td>3</td>
        <td>5</td>
        <td>8</td>
      </tr>
    </li>
    <li class="ui-state-default">
      <tr>
        <td>Ryan</td>
        <td>8</td> 
        <td>7</td>
        <td>0</td>
        <td>7</td>
        <td>26</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Kyle</td>
        <td>10</td> 
        <td>3</td>
        <td>6</td>
        <td>9</td>
        <td>8</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Sean</td>
        <td>8</td> 
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>8</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Seth</td>
        <td>11</td> 
        <td>4</td>
        <td>1</td>
        <td>5</td>
        <td>47</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Kyle Z</td>
        <td>8</td> 
        <td>2</td>
        <td>0</td>
        <td>2</td>
        <td>0</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Gary</td>
        <td>10</td> 
        <td>7</td>
        <td>3</td>
        <td>10</td>
        <td>6</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Mark</td>
        <td>12</td> 
        <td>6</td>
        <td>5</td>
        <td>11</td>
        <td>30</td>
      </tr>
    </li>
    <li class="ui-state-default">
       <tr>
        <td>Mike</td>
        <td>12</td> 
        <td>1</td>
        <td>6</td>
        <td>7</td>
        <td>0</td>
      </tr>
    </li>
    <li class="ui-state-default">
      <tr>
        <td>Tim</td>
        <td>1</td> 
        <td>0</td>
        <td>1</td>
        <td>1</td>
        <td>2</td>
      </tr>
    </li>
    </ul>
    </tbody></table>

CSS -

 #sortable { 
  list-style-type: none; margin: 0; padding: 0; width: 60%; 
}

 #sortable li { 
  margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; 
}

 #sortable li span { 
  position: absolute; margin-left: -1.3em; 
}

2 个答案:

答案 0 :(得分:0)

尝试重新安排链接和脚本标记,看看是否可以。可能是某些事情凌驾于其他事情之上:

<link rel="stylesheet" href="./Bombers Hockey_files/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link href="./Bombers Hockey_files/hockey.css" rel="stylesheet" type="text/css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="./Bombers Hockey_files/bootstrap.min.js.download" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<script src="./Bombers Hockey_files/jquery.min.js.download"></script>
<script src="./Bombers Hockey_files/popper.min.js.download"></script>

答案 1 :(得分:0)

<ul><li>内使用<tbody>标记无效且不必要,因为<tr><td>元素基本上是列表。只需使您的表的<tbody>可排序就可以了。

https://jsfiddle.net/66mj031n/