Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Realice un seguimiento de los cambios en varias instancias de Ckeditor 5 en Javascript

Estoy accediendo a un iframe a través de fancybox 3 con múltiples ckeditor . Está funcionando bien, pero quiero rastrear si un usuario ha ingresado algo en los cuadros de texto para poder cambiar el botón del cuadro elegante y darles una alerta una vez que presionen cerrar. Este es mi código JS en la página iframe:

 window.editors = {}; document.querySelectorAll( '.editor' ).forEach( ( node, index ) => { ClassicEditor .create( node, { removePlugins: ['Heading', 'BlockQuote', 'CKFinderUploadAdapter', 'CKFinder', 'EasyImage', 'Image', 'ImageCaption', 'ImageStyle', 'ImageToolbar', 'ImageUpload', 'MediaEmbed'], } ) .then( newEditor => { window.editors[ index ] = newEditor; } ); editors[ index ].document.on( 'change', () => { console.log( 'Alert: The document has changed!, are you sure you want to close without saving?' ); } ); } );

Pero me está dando un error:

 ifram.php:1070 Uncaught TypeError: Cannot read properties of undefined (reading 'document') at ifram.php:1070 at NodeList.forEach (<anonymous>) at ifram.php:1060

También intenté sacar esto de la función document.querySelectorAll()

 editors.document.on( 'change', () => { console.log( 'Alert: The document has changed!, are you sure you want to close without saving?' ); } );

Pero me dio otro error: Uncaught TypeError: Cannot read properties of undefined (reading 'on')

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Podría usar el documento newEditor.model.document.on('change:data')

 <script src="https://cdn.ckeditor.com/ckeditor5/30.0.0/classic/ckeditor.js"></script> <textarea class="editor"></textarea> <script> window.editors = {}; document.querySelectorAll( '.editor' ).forEach( ( node, index ) => { ClassicEditor .create( node, { removePlugins: ['Heading', 'BlockQuote', 'CKFinderUploadAdapter', 'CKFinder', 'EasyImage', 'Image', 'ImageCaption', 'ImageStyle', 'ImageToolbar', 'ImageUpload', 'MediaEmbed'], } ) .then( newEditor => { window.editors[ index ] = newEditor; newEditor.model.document.on('change:data', ()=> { console.log( 'Alert: The document has changed!, are you sure you want to close without saving?' ); }); } ); }); </script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!