Add class to field on editor open event

Add class to field on editor open event

YaniYani Posts: 24Questions: 7Answers: 0

I am trying to add a class to a field with a simple editor 'open' handler:

editor.on('open', function(e, mode, action) {
        if (mode == 'inline' && action == 'edit') {
            $(this).addClass('no-padding');
        }
    });

However, I am unable to select the td element to add the class. How would I do this? Thanks.

This question has an accepted answers - jump to answer

Answers

  • YaniYani Posts: 24Questions: 7Answers: 0

    I have found a solution for this. I don't think it's the best way but it works:

    editor.on('open', function(e, mode, action) {
        if (mode == 'inline' && action == 'edit') {
            $(e.target.s.modifier).addClass('no-padding');
        }
    });
    
  • YaniYani Posts: 24Questions: 7Answers: 0

    Now for some reason, the modifier changed from the td element to an object:

    modifier: {
        column: 7,
        columnVisible: 5,
        row: 0
    }
    

    is there a consistent way to grab the td? I'd be very thankful if somebody could help me out here.

  • YaniYani Posts: 24Questions: 7Answers: 0

    I'm still struggling with this.

    Sadly, the modifier is inconsistent and I've not found anything else.

    I'm sure this use case would be common?

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    I'd suggest using:

    $('div.DTE').closest('td')
    

    That will select the Editor container element for the inline edit, which is inside the cell (when inline editing) and then get the container cell.

    Regards,
    Allan

  • YaniYani Posts: 24Questions: 7Answers: 0

    Thanks Allan. That's exactly what I was looking for.

    How come there is no documented functionality for this?

This discussion has been closed.