Standalone datetime field in editor

Standalone datetime field in editor

Edwin1966Edwin1966 Posts: 9Questions: 4Answers: 0

I made a standalone datetime field with the new Editor.
How can I trigger the field to show the default value?

I need this (http://jsfiddle.net/5rpty/1/) functionality but I try to do it with the Editor all the way.

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../lib/DataTables-1.10.10/extensions/Editor-PHP-1.5.3/css/editor.dataTables.min.css">
    <style>
        dt { margin-top: 1em; }
        dt:first-child { margin-top: 0; }
        dd { width: 25% }

        *[data-editor-field] {
            border: 1px solid #ccc;
            padding: 0.5em;
            margin: 0.5em;
        }
    </style>
    <script type="text/javascript" language="javascript" charset="utf-8" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" language="javascript" charset="utf-8" src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" language="javascript" charset="utf-8" src="../lib/DataTables-1.10.10/extensions/Editor-PHP-1.5.3/js/dataTables.editor.min.js"></script>

<script>
    var editor; // use a global for the submit and return data rendering in the examples

    $(document).ready(function() {
        editor = new $.fn.dataTable.Editor( {
            ajax: "",
            fields: [ 
                {
                    label: 'date-start',
                    name:  'date-start',
                    type:  'datetime',
                    def:   function () { return new Date(); }
                }
            ]
        } );

        $('[data-editor-field]').on( 'click', function (e) {
            editor.inline( this, {
                onBlur: 'submit'
            } );
        } ); 
    } );
</script>
</head>
<body>
    <p>
        Standalone datetime field.<br>
        How can I trigger the field to show the default value on first show?<br>
        I need this (http://jsfiddle.net/5rpty/1/) functionality but I try to do it with the Editor all the way.

    </p>
    <dl>
        <dt data-editor-label="date-start">Date:</dt>
        <dd data-editor-field="date-start"></dd>
    </dl>
    <input type="reset" value="RESET" />
</body>
</html>
This discussion has been closed.