event invoking and parameters

event invoking and parameters

Yang.SongYang.Song Posts: 23Questions: 4Answers: 0

I was playing with datatable and keep the editor (always visible editing panel setup). When I switch rows in the datatable, only "preClose" is invoked and I cannot invoke "preEdit". I have two questions - how do you invoke "preEdit" and what are the parameters passed to these event handlers? The examples shows e or type and I'm guessing "e" is editor and not sure what "type" is.

 editor
      .on( 'open',  function ( e, type ) {
          openVals = JSON.stringify( editor.get() );        
      } )
      .on( 'preSubmit', function ( e ) {
          alert("preSubmit :"+JSON.stringify( editor.get()) +" ====== "+ openVals);  
          if ( openVals !== JSON.stringify( editor.get() ) ) {
              return confirm( 'You have unsaved changes. Are you sure you want to exit?' );
          }
      } )
       .on( 'preEdit', function ( e ) {
          alert("preEdit :"+editor.get() +" ====== "+ openVals);  
          if ( openVals !== JSON.stringify( editor.get() ) ) {
              return confirm( 'You have unsaved changes. Are you sure you want to exit?' );
          }
      } )
       .on( 'preCreate', function ( e ) {
          alert("preCreate :"+editor.get() +" ====== "+ openVals);  
          if ( openVals !== JSON.stringify( editor.get() ) ) {
              return confirm( 'You have unsaved changes. Are you sure you want to exit?' );
          }
      } )
       .on( 'preClose', function ( e ) {
          alert("preClose :"+"\n"+ JSON.stringify( editor.get()) +"\n"+ openVals);  
          if ( openVals != JSON.stringify( editor.get() ) ) {
              return confirm( 'You have unsaved changes. Are you sure you want to exit?' );
          }
      } ); 

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    There's more information on the reference pages for the events, such as preEdit. Hope that helps,

    Colin

  • Yang.SongYang.Song Posts: 23Questions: 4Answers: 0

    Thank you! That does give me more information on how to make the call. However, it does not tell me why it's not invoked or if keeping the editor as always persistent changed the default behavior?

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    However, it does not tell me why it's not invoked or if keeping the editor as always persistent changed the default behavior?

    The default behaviour wouldn't have changed, and I'm not sure why it's not being called without seeing your code in action. Are you able to link to your page so we can take a look?

    Colin

This discussion has been closed.