In the click handler of an Editor field, how to detect the context surrounding the field?

In the click handler of an Editor field, how to detect the context surrounding the field?

DT ProgerDT Proger Posts: 18Questions: 5Answers: 0

Please click the following link to run the test case:

http://58.64.211.82/Ed/examples/advanced/localStore4.html

In the "item" field, i have coded an event handler for the click event, as follows:

editor.field( 'item' ).input().on( 'click', function () {
alert("Did the User just click on Create light-box field, or Edit light-box field, or Datatable cell? How to detect?");
} );

The outcome is that whenever the User clicks on the "item" field, it pops up an alert message box. As simple as that.

However, there could be three possibilities:

  1. The user clicked on one of the "item" cell in the Datatable body.

  2. The user clicked on the "item" field inside the "Create new entry" light-box.

  3. The user clicked on the "item" fiield" inside the "Edit entry" light-box.

The obvious question is:

In the click event handler of the "item" field, how to detect which of the above three cases it is?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Answer ✓

    Hi,

    The link above doesn't appear to be loading, however, thanks to your clear description I think I can help without it.

    The display() method is the first stop - it will tell you if the form is in lightbox (main) mode, inline or bubble editing. That will help with 1 which I assume is referring to inline editing.

    For 2 and 3 use mode() which will tell you if the form is in create or edit state.

    Regards,
    Allan

  • DT ProgerDT Proger Posts: 18Questions: 5Answers: 0

    Thank you so much for that. The display() and mode() methods are exactly what I needed.

This discussion has been closed.