Display a list of elements from a view to a modal in jquery

3

Suppose I have a list of elements in a view:

<% Dim valor As New List(Of Integer)
For i As Integer = 0 To 5%>    
<%valor.Add(i)%>
<% Next%>

I send them to a modal using data in this way:

<a href="#" data-toggle="modal" data-target="#modal_noticia_editar" data-valores='<%:valor%>'  data-noticiaid='<%: item.IdNoticia%>' data-titulo='<%: item.TituloNoticia%>' data-descripcion='<%: item.DescripcionNoticia%>' class="noticia_edit">Editar</a>

And when the modal opens, I see data where I do it this way:

    $('.noticia_edit').click(function (e) {
        e.preventDefault();

        NoticiaID = $(this).data('noticiaid');
        Titulo = $(this).data('titulo');
        Descripcion = $(this).data('descripcion');
        valores = $(this).data('valores');


        $("#modal_noticia_editar input[name=noticiaid]").val(NoticiaID);
        $("#modal_noticia_editar input[name=titulo]").val(Titulo);
        $("#modal_noticia_editar input[id=Descripcion_edit]").val(Descripcion);
        $("#modal_noticia_editar input[id=foto_multi]").val(valores);

    });

In this line $ ("# modal_noticia_editar input [id = foto_multi]"). val (); At val, I must pass the "values" list. For this I need to go through the list and I would like to know how to send the elements of list values with jquery or javascripts to the val input [id = foto_multi] ") so that the elements of this list are displayed.

    
asked by Danilo 11.01.2016 в 16:52
source

1 answer

1

You could see using

<% Dim items As New List(Of String)
   For i As Integer = 0 To 5    
      items.Add(i.ToString())
   Next
   Dim valor As String = String.Join(",", items)
%>

then when you use the data-values = '<%: value% >' you would be passing these separated by comma, in the val () they would be shown directly

    
answered by 11.01.2016 / 18:03
source