Can .set access a function

Can .set access a function

obrienjobrienj Posts: 93Questions: 38Answers: 0
edited September 2017 in Editor

I have the following code:

            $('#cc-list').on('click', 'a.editor_copy', function (e) {
                e.preventDefault();

                // get the current row
                copyrow = $(this).closest('tr');

                // in case all row data not loaded, get index of selected row
                var ix = copyrow["0"]._DT_RowIndex;

                // get all the data for the selected row
                rowdata = table.row(ix).data();

                // copy actually does a 'create' but with fields populated from the current (copied) row
                editor
                    .create({
                        title: 'Create event',
                        buttons: [
                           'Add'
                           //{ label: 'Cancel', fn: function () { this.close(); } }
                        ]
                    })
                    .set({
                        title: rowdata['title'],
                        allDay: '0',
                        action: '0',

                        locHolder: function() {copyLoc(rowdata);},

                    })
            });

This is the code that supports a "copy" function that I include on every row in the datatables list window, that is,

Edit / Copy / Delete

I have verified the the function "copyLoc" returns the correct value but it doesn't appear in the field when the editor window appears.

Note that "title:", "allDay:, and "action:" all refer to valid columns in the database, but "locHolder:' only exists on the editor window and is constructed by "copyLoc".

Is this valid coding?

Regards,
Jim

Answers

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

    Try this:

            .set({
                title: rowdata['title'],
                allDay: '0',
                action: '0',
                locHolder: copyLoc(rowdata),
            })
    

    As it was you were assigning a function to the locHolder parameter. You could execute that function immediately, but just calling copyLoc directly would do the same thing.

    Allan

This discussion has been closed.