Editor Event

Editor Event

wblakencwblakenc Posts: 77Questions: 17Answers: 1
edited February 7 in Editor

Link to test case: https://live.datatables.net/kumiwisi/10/edit

Description of problem: Hello all. I am trying to do something that seems simple but just doesn't seem to work. I have an editor instance with a custom form layout. In this layout is some static text and elements (legend, HR) that I want to start out hidden. I am using bootstrap and adding a class of d-none. This works well, except I cannot figure out how to remove the class once the editor form is open. I tried using the initEditor event remove the class once editor has fully been instantiated. Anyway, I cant get the event to fire. See above link. Shouldn't the example above print in the console when the form is displayed? I have tried using initEdit and it fires, but does not seem to allow me to remove or add a class to a static element. Thoughts?

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406
    edited February 7 Answer ✓

    Your example crashes when trying to edit a record.
    It doesn't work either when you try to create a new record. Nothing is written to the console.

    But if you replace:

    $(document).on( 'initEditor', function ( e, inst ) {
        inst.on( 'opened', function () {
            console.log( 'Form displayed' );
            // ... add event handlers
        } );
    } );
    

    with

    editor.on( 'opened', function () {
        console.log( 'Form displayed' );
        // ... add event handlers
    } );
    

    "Form displayed" is being written to the console - in case you are creating a new record.

  • wblakencwblakenc Posts: 77Questions: 17Answers: 1
    edited February 8

    Thanks for the answer. Not sure why InitEditor isn't firing. But 'opened' works like a charm.

    I know in my example the edit doesn't work, and there is nothing running to make the new work, I was just using it as example of the form and the event.

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406

    "InitEditor" is supposed to be something extraordinary. Before you posted this I wasn't even aware that it existed :smile:

    Glad you got this resolved!!

  • kthorngrenkthorngren Posts: 20,358Questions: 26Answers: 4,777

    The event is initEdit not initEditor.

    Kevin

  • rf1234rf1234 Posts: 2,809Questions: 85Answers: 406

    Hey Kevin! How are you? That was exactly my thinking! And then I found this:
    https://editor.datatables.net/reference/event/initEditor

    lol

    Roland

  • kthorngrenkthorngren Posts: 20,358Questions: 26Answers: 4,777

    I see :-).

    Kevin

Sign In or Register to comment.