compare preEdit and postEdit data

compare preEdit and postEdit data

crush123crush123 Posts: 417Questions: 126Answers: 18

i have an editor instance with an ajax object source, where i want to call a function if (and only if) the email address has been changed

i can log the json data for preEdit and postEdit, but is it possible to compare, (and if so is it the best way) ?

This question has an accepted answers - jump to answer

Answers

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited March 2016

    actually, in answer to my own question, I think i want to be comparing InitEdit and PostEdit.

    var emailbefore;
    
    editor
        .on( 'initEdit', function ( e, node, data ) {
         emailbefore = data.tblmembers.EmailAddress1;
        })
        .on( 'postEdit', function ( e, json, data ) {
         if (emailbefore == data.tblmembers.EmailAddress1) {
            console.log('EMAIL IS THE SAME');
         } else {
            console.log('EMAIL HAS CHANGED');
         }
    });
    
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    You are correct - initEdit is the event to use to get the value when editing is started. The preEdit naming choice is a little poor (legacy).

    Allan

This discussion has been closed.