Standalone Create and Update Problem

Standalone Create and Update Problem

YukiYuki Posts: 2Questions: 2Answers: 0
edited April 2017 in Free community support

I am facing a problem of using standalone. It cannot initialize the field after the Editor is loaded. And after updating the column, the new data cannot be replace, and all the DOM code is stored as raw text inside the input place.
Here is my code:

HTML:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

    <title>DataTables Editor - Community</title>

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.14/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="css/editor.dataTables.min.css">

    <script type="text/javascript" charset="utf-8" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript" charset="utf-8" src="https://cdn.datatables.net/1.10.14/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/dataTables.editor.min.js"></script>
    <style>
      dt { margin-top: 1em; }
      dt:first-child { margin-top: 0; }
      dd { width: 25% }

      *[data-editor-field] {
        border: 1px dashed #ccc;
        padding: 0.5em;
        margin: 0.5em;
      }

      *[data-editor-field]:hover {
        background: #f3f3f3;
        border: 1px dashed #333;
      }
    </style>
  </head>
  <body class="dataTables">
    <h1>
      Community
    </h1>

    <div class="display" id="community">
      <div data-editor-id="1">
        <div style="width: 10%; float: left;" data-editor-label="communityname">Community Name:</div>
        <div style="width: 10%; float: left;" data-editor-field="communityname"></div>
        <div style="width: 10%; float: left;" data-editor-label="description">Description:</div>
        <div style="width: 10%; float: left;" data-editor-field="description"></div>
      </div>
    </div>
 </body>
</html>

JS:

$(document).ready(function () {

        editor = new $.fn.dataTable.Editor({
          ajax: "php/table.community_standalone.php",
          fields: [
            {
              "label": "CommunityName:",
              "name": "communityname"
            },
            {
              "label": "Description:",
              "name": "description"
            }
          ]
        });

        $('[data-editor-field]').on('click', function (e) {
          editor.inline(this, {
            buttons: '_basic'
          });
        });
      });
})

PHP:

$communityId = 1;
Editor::inst( $db, 'Community', 'CommunityID' )
    ->fields(
        Field::inst( 'communityid' )->set( false ),
        Field::inst( 'communityname' ),
        Field::inst( 'description' )
        )
        ->where('communityid', $communityId)
    ->process( $_POST )
    ->json();

What should I do to solve this one?

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Could you give me a link to the page showing the issue so I can debug it please? That actually looks like it should work since you are using repeating tabular data.

    Allan

This discussion has been closed.