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

269
Views
No se puede publicar el valor de TextArea usando el editor WYSIWYG en Razor Pages

Estoy desarrollando una aplicación .NET Core 3.1 Razor Pages. Una de las páginas de Razor dentro de mi aplicación publica el contenido de un TextArea usando AJAX. Esto funciona como se esperaba, sin embargo, cuando uso CKEditor 5 https://ckeditor.com/ckeditor-5/ y convierto TextArea en un editor WYSIWYG, ya no puedo publicar los valores dentro del editor.

Tenga en cuenta que CKEditor se carga como se esperaba y no hay errores cuando uso las herramientas para desarrolladores en Google Chrome.

Modelo de página

 [BindProperty] public InputModel Input { get; set; } public PartialViewResult OnPostMyTestPartial() { //Some logic then return data for partial } public class InputModel { public int Id { get; set; } public string Narrative { get; set; } }

CSHTML

 <form> <!-- Other html --> <textarea asp-for="Input.Narrative"></textarea> <button class="btn btn-primary" id="load">Update</button> </form>

JQuery

 $(document).ready(function () { $('#load').on('click', function (evt) { evt.preventDefault(); $.post("/MyPage/Index?handler=MyTestPartial", $('form').serialize(), function (data) { $("#myPartial").html(data); }); }); ClassicEditor .create(document.querySelector('#Input_Narrative'), { toolbar: ['heading', '|', 'bold', 'italic', 'link'] }) .then(editor => { window.editor = editor; }) .catch(err => { console.error(err.stack); }); });

Cuando comento el código de ClassicEditor en mi archivo JQuery para que TextArea permanezca puramente como TextArea, puedo ver a través de Developer Tools y la depuración en Visual Studio que el valor se publica correctamente:

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

Sin embargo, cuando convierto TextArea en un editor usando CKEditor e intento publicar datos, los datos no se publican.

ingrese la descripción de la imagen aquí ingrese la descripción de la imagen aquí

¿Puede ayudarme alguien, por favor?

Gracias.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe transferir manualmente el contenido del editor al control de formulario:

 $('#load').on('click', function (evt) { evt.preventDefault(); $('#Input_Narrative').val(CKEDITOR.instances['Input_Narrative'].getData()); $.post("/MyPage/Index?handler=MyTestPartial", $('form').serialize(), function (data) { $("#myPartial").html(data); }); });

https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/saving-data.html#manualmente-recuperando-los-datos

over 4 years ago · Santiago Trujillo 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!