線上書籍

Home

網站程式設計-PHP

  1. jquery ui 官網:https://jqueryui.com/
  2. 從官網下載stable 版,然後將「jquery-ui.css」「jquery-ui.js」複製到 class/jQueryUi

     
  3. 這裡用商品類別管理為範例 admin/kind.php
  4. 所以編輯樣板 /templates/admin/theme.html

     
  5. 在類別管理 {* 類別管理 列表 *} {if $WEB.file_name == "kind.php" and $op == "op_list"}

    加入
     

    <link rel="stylesheet" href="../class/jQueryUi/jquery-ui.css" type="text/css" /> <script src="../class/jQueryUi/jquery-ui.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { //排序 $('#sort').sortable(); }); </script>

     

  6. 在父元素(tbody) 設定 id="sort" 在本身(tr) 設定 id="tr_{$row.sn}"

     
  7. 這樣應該就可以拖曳排序了,但更新資料庫就必須使用 AJAX(這個再找時間來說了)