Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
How can I add new button to new row in javascript(MVC 5)?

I am Beginner. Thank you! i have 2 button Delete and Edit, it show when refresh after i add 1 new row. I need show them without F5, can you fix my AJAX, after i add 1 new row, no button show, i need F5 to refresh page to load it from database. Can you rewrite my 'var tr' .Thank you! My ID = @ViewBag.NewID My HOME CONTROLER: u.ID = Guid.NewGuid().ToString(); ViewBag.NewID = u.ID;

  <table id="UserList">
        <tr>
            <th>Username</th>
            <th>Password</th>
            <th>Name</th>
            <th>Action</th>
        </tr>
        @foreach (Database_Users item in Model)
        {
            <tr id="tr_@item.ID">
                <td class="uid">@item.Uid</td>
                <td class="pwd">@item.Pwd</td>
                <td class="name">@item.Fullname</td>
                <td>
                // THERE ARE 2 BUTTON I NEED CREAT WITHOUT REFRESH
                    <a href="javascript:Delete('@item.ID','@item.Fullname')">
                        [Delete]
                    </a>
                    &nbsp;
                    <a href="javascript:BeginEdit('@item.ID','@item.Uid','@item.Fullname')">
                        [EDIT]
                    </a>
                </td>
            </tr>
        }
    </table>
    <script>    
        function AddNewUser() {               
                       
                        // My ID = @ViewBag.NewID                           
                        //ADD 1 ROW --- NEED 2 button show = AJAX
                        var tr = '<tr><td>' + uid + '</td><td>' + pwd1 + '</td><td>' + name + '</td><td></td></tr>';                                                
                        
                        $('#UserList').append(tr);                  
                                             
            }              
        }   
    </script>

My View after add 1 new row, i need 2 button show by AJAX

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In AddNewUser function you can replace this line, but if you have this newely created ID // My ID = @ViewBag.NewID

    var tr = `<tr><td>  ${uid}} </td><td> ${pwd1} </td><td> ${name}</td><td>  <a href="javascript:Delete("${uid}","${name}")">[Delete]</a>&nbsp;<a href="javascript:BeginEdit("${ID}","${uid}","${name}")">[EDIT]</a> </td></tr>`;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda