Dynamic Divs from the data of a model

0

I need to create a view with razor, that with data of a model, I generate different DIVs dynamically giving them an ID to each of them, that allows me to identify them when the user selects them using javascript.

I have a model that has a list of patients, which I need to present on screen.

And I have in a part of the screen a foreach that iterates in the list of patients

@foreach (var paciente in Model)

{

   // aca tengo el div que identifica a 1 paciente

  <div class="item" id=model.PacienteId + "_id">

      <div class="titulo">model.NombrePaciente</div>

      <div class="titulo">model.edad</div>

  </div>

}

This although it compiles well, and does not give errors at the time of execution, it does not generate the divs with different IDs.

Does anyone know how this is done?

My idea is to be able to then select the objects on the screen through a checkbox.

Thanks

    
asked by Luis Gabriel Fabres 23.03.2017 в 15:20
source

1 answer

0

I use the same thing for a project with jQuery and it works perfectly. If you add a for you can create all the divs you want ...

jQuery("#div_precios" ).append('<div id="precio_' +  cantidad_precios +'"  class="precio_actividad">');
    
answered by 23.03.2017 / 15:30
source