G
G
GaserV2016-12-17 17:59:23
Ember.js
GaserV, 2016-12-17 17:59:23

How to implement user editing?

Tell me please. There is a table in which the list of users is deduced. At the end there is a cell in which there is a button to update the user. When the button is clicked, action: updateUser() is called, where the user data will be updated accordingly. So. How to get this data if there is no form?
view:

<table class="table table-striped">
            <thead>
              <tr>
                <th>#</th>
                <th>firstname</th>
                <th>lastname</th>
                <th>email</th>
                <th>phone</th>
                <th></th>
              </tr>
            </thead>
            <tbody>
            	{{#each model as |user index|}}
              <tr>
          <td>{{ index }}</td>
          <td contenteditable="true">{{ user.firstname }}</td>
          <td contenteditable="true">{{ user.lastname }}</td>
          <td contenteditable="true">{{ user.email }}</td>
          <td contenteditable="true">{{ user.phone }}</td>
          <td>
            <!-- {{#link-to 'user.edit' user.id class="btn btn-warning btn-sm"}}Edit{{/link-to}} -->
            <button {{action 'updateUser' user}} class="btn btn-warning btn-sm">Update</button>
            <button {{action 'deleteUser' user}} class="btn btn-danger btn-sm">Delete</button>
          </td>
              </tr>
              {{else}}
              no records
              {{/each}}
            </tbody>
          </table>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Romanov, 2016-12-17
@Kaer_Morchen

What are data updates? Get fresh data from the server?
If you are using ember-data, you can use the reload method .

actions: {
    updateUser(user) {
       user.reload();
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question