Problem with set() and val() functions

Problem with set() and val() functions

milapmilap Posts: 40Questions: 13Answers: 2
edited January 2016 in Editor

Hello,

I have a problem with functions set() and val()

I have created new page at my server with extracted from Editor-PHP-1.5.4.zip files only.

The only 2 files that I have modified are:

1) php/config.php (hostname and credentials for database connection)

2) examples/simple/simple.html

In the second file in line 68th I have added one line:

editor.field('first_name').set("MAKING YOU HAPPY");

And when I call simple.html in my browser the "First name" field (which supposed to make me happy) is empty :(

editor.field('first_name').val("MAKING YOU HAPPY"); // don't work either
editor.set('first_name',"MAKING YOU HAPPY"); //don't work
editor.val('first_name',"MAKING YOU HAPPY"); //don't work

editor.field('first_name').def("MAKING YOU HAPPY"); // the only one that works...

Is this a bug or am I doing something wrong?

Since obviously problem is with js then it should not be related with my www server configuration (js is running in browser). I am using new chrome and firefox.

Full js code of simple.html (additional code in line 32nd):

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

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "../php/staff.php",
        table: "#example",
        fields: [ {
                label: "First name:",
                name: "first_name"
            }, {
                label: "Last name:",
                name: "last_name"
            }, {
                label: "Position:",
                name: "position"
            }, {
                label: "Office:",
                name: "office"
            }, {
                label: "Extension:",
                name: "extn"
            }, {
                label: "Start date:",
                name: "start_date",
                type: "datetime"
            }, {
                label: "Salary:",
                name: "salary"
            }
        ]
    } );
     editor.field('first_name').set("MAKING YOU HAPPY");
    $('#example').DataTable( {
        dom: "Bfrtip",
        ajax: "../php/staff.php",
        columns: [
            { data: null, render: function ( data, type, row ) {
                // Combine the first and last names into a single table field
                return data.first_name+' '+data.last_name;
            } },
            { data: "position" },
            { data: "office" },
            { data: "extn" },
            { data: "start_date" },
            { data: "salary", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );
} );

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.