How can I add objects to a List in the PageModel and have the view updated without sending the POST?

0

I am new to Razor Pages and I want to add a product to a list that is included in the PageModel and display the list in a table, but when adding a product to the list the section of the table is updated.

    
asked by M. Brandle 22.06.2018 в 21:42
source

1 answer

0

that is done by javascript just refer to your elements where it says col 1 and col 2 is a simple example.

$('#add').on('click', function(){
  html = '<tr><td>col 1</td>';
  html += '<td>col 2</td></tr>';
  
  $('tbody').append(html)
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="add">añadir nuevo</button>
<table class="table">
  <thead>
    <tr>
      <th scope="col">#</th>
      <th scope="col">First</th>
    </tr>
  </thead>
  <tbody>
    
  </tbody>
</table>
    
answered by 22.06.2018 / 22:11
source