Add 'Cancel' button to in table form controls

Add 'Cancel' button to in table form controls

Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

Sorry if this is an obvious question but I cannot figure out how to add a 'cancel' button when using in table form controls? This is used to remove a row from the table and I would like to add a cancel button,

    // Delete a record
    $('#cms_module_system_tasks').on('click', 'a.editor_remove', function(e) {
        e.preventDefault();
        editor.message('Are you sure you wish to remove this record?').buttons('Delete').remove($(this).closest('tr'));
    });

Can anyone point me in the direction of a working example?

Thanks

Answers

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

    Hi,

    Possibly the best way is to use the form-options parameter which you can pass into remove(). For example your above call might become:

    editor.remove( $(this).closest('tr'), {
      message: "Are you sure you wish to remove this record?",
      buttons: [
        'Save',
        { label: 'Cancel', fn: function () { this.close(); } }
      ]
    } );
    

    The form-options is good for this sort of thing as it removes any asynchronous issues that can crop up should you happen to be using inline editing or bubble editing.

    Regards,
    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Hi Allan,

    Thanks for your help. For anyone who might also be interested here is the final code I used.

            // Delete a record
            $('#cms_module_system_files').on('click', 'a.editor_remove', function(e) {
                e.preventDefault();
                editor.remove($(this).closest('tr'), {
                    message : "Are you sure you wish to remove this record?",
                    buttons : ['Delete', {
                        label : 'Cancel',
                        fn : function() {
                            this.close();
                        }
                    }]
                });
            });
    

    Cheers

    Chris

This discussion has been closed.