Format HTML to show in the view

0

I am using Laravel 5.4, and I retrieve a text from the formatted database using ckeditor

<p><strong>Lorem ipsum dolor sit amet, consectetu</strong></p>

I know that the blade uses {!! !!} to format it but this time I use ajax, and I want to set this text in a Laravel accessor

public function getNoticiaAttribute($value)
{
    return $value;
}

Here I would have to return the value set as if it were blade with {!! !!}

The information provided is by axios:

searchData() {
   axios.post('/news/search', $('#frmSearchNews').serialize()).then(res => {
      this.noticias = res.data;
   });
}
    
asked by Juan Pablo B 17.04.2018 в 15:35
source

1 answer

0

by default when you use ckeditor this generates html code which you keep in your database and you re-create it you could identify the area where you want to add the text by an example id

<h2 id="myIdH2">textoz</h2>

to put any value in the serial by javascript:

document.getElementById("myIdH2").innerHTML = "lo que sea";

I hope it's useful to you!

    
answered by 17.04.2018 в 20:12