官網: https://vitalets.github.io/x-editable/
use XoopsModules\Tadtools\Bootstrap3Editable;
使用方法
$Bootstrap3Editable = new Bootstrap3Editable();
$Bootstrap3EditableCode = $Bootstrap3Editable->render('.editable', 'ajax.php');
$xoopsTpl->assign('Bootstrap3EditableCode', $Bootstrap3EditableCode);
樣板檔部份的範例
<a href="#" class="editable editable-click editable-empty" data-name="award" data-type="select" data-pk="9" data-params="{'op':'save_grade','type':'award'}" data-title="選擇名次或獎項" data-value="" data-source="[{'value':'第一名','text':'第一名'},{'value':'第二名','text':'第二名'},{'value':'第三名','text':'第三名'},{'value':'佳作','text':'佳作'}]">Empty</a>
data-type
:輸入類型 (text, textarea, select)data-pk
:主索引的值,也可以這樣寫 {id: 1, lang: 'en'}
data-id
or data-name
:主索引的名稱data-value
:預設值,如果是空白,就是以原本內容為主ajax.php 範例:
<?php
use Xmf\Request;
include "header.php";
$op = Request::getString('op');
$old_name = Request::getString('old_name');
$name = Request::getString('name');
$value = Request::getString('value');
$pk = Request::getInt('pk');
switch ($op) {
case 'rename':
$sql = "update " . $xoopsDB->prefix("mod_make_sql") . " set `sql_name`='{$value}',`sql`=replace(`sql`,'CREATE TABLE `{$old_name}`','CREATE TABLE `{$value}`') where mssn='{$pk}'";
$xoopsDB->queryF($sql) or die($sql);
exit;
}
官網文件: http://vitalets.github.io/x-editable/docs.html