as samples my data without the labels I keep tinymce?

0

I have a small problem, what happens is that I'm doing a forum in laravel, and where they are supposed to put the description or code integrated e tinymce for it, to save the data in the DB is not the problem, what I'm doing is making a select in the controller and I send it to the view with all the data as an array, which I go through with a forech but this shows me with the tags as it was saved in the db and for this I use this code and it shows me in plain text, what I want:

@foreach($mensajes as $m)
<textarea id="resp-hide" class="ultima-respuesta-hide" style="display: none">{{ $m->comment }}</textarea>
    <p id="ult-respuesta" class="ultima-respuesta"></p>
@endforeach

This script is what translates me to plain text so to speak

<script>
    . var traducirHTML = document.getElementById("resp-hide").value;
      document.getElementById("ult-respuesta").innerHTML = traducirHTML;
    </script>

That shows me only the text and it's perfect, but when you enter another comment it does not work anymore, it only works with one comment, it does not show anything if it's more than one comment, someone knows how I do to show me the other comments also but without the labels? Is there another way?

    
asked by Cristian Veizaga 02.02.2017 в 21:50
source

1 answer

0

I think your problem could be resolved by adding that script to a function and executing it after another comment is added, eg:

@foreach($mensajes as $m)
<textarea id="resp-hide" class="ultima-respuesta-hide" style="display: none">{{ $m->comment }}</textarea>
    <p id="ult-respuesta" class="ultima-respuesta"></p>
<script>traducir();</script>
@endforeach

<script>
function traducir() {
    . var traducirHTML = document.getElementById("resp-hide").value;
      document.getElementById("ult-respuesta").innerHTML = traducirHTML;
}
</script>

Or what would be more correct, try to register the event when another comment is entered, and execute the script below.

    
answered by 11.02.2017 в 21:32