JavaScript Aurelia binding - back to view model on button click

You can create a model object for your edit popup and only copy the edits made to the item in the list when Save is clicked. Here's a simplified example: https://gist.run/?id=af3af031c5acc4c46407679f5ab1376b

View

<template>
  <ul>
    <li repeat.for="person of people">${person.firstName} ${person.lastName} <button click.delegate="editPerson(person)">Edit</button></li>
  </ul>
  <div if.bind="editing">
    First Name: <input type="name" value.bind="editModel.firstName" />
    Last Name: <input type="name" value.bind="editModel.lastName" />
    <button click.delegate="savePerson()">Save</button>
    <button click.delegate="cancelEdit()">Cancel</button>
  </div>
</template>

ViewModel

export class App {
  editing = false;
  people = [
    { firstName: 'John', lastName: 'Doe' },
    { firstName: 'Jane', lastName: 'Smith' },
    { firstName: 'Bob', lastName: 'Smith' }
  ];

    editPerson(person) {
      this.editing = true;
      this.editObject = person;
      this.editModel = Object.assign({},person);
    }
    savePerson() {
      this.editing = false;

      Object.assign(this.editObject, this.editModel);

      this.editObject = null;
      this.editModel = null;
    }

    cancelEdit() {
      this.personBeingEdited = null;
      this.editing = false;
    }
}
Answer:1

I have a value from JavaScript: var customerID = document.getElementById("CustomerID").value; Now I want query the firstName, lastName from module data, based on that customerID variable. {...

I have a value from JavaScript: var customerID = document.getElementById("CustomerID").value; Now I want query the firstName, lastName from module data, based on that customerID variable. {...

  1. pass javascript variable to php
  2. pass javascript variable to html
  3. pass javascript variable to c#
  4. pass javascript variable to python
  5. pass javascript variable to razor
  6. pass javascript variable to php function
  7. pass javascript variable to flask
  8. pass javascript variable to url.action
  9. pass javascript variable to django
  10. pass javascript variable to css
  11. pass javascript variable to jinja2
  12. pass javascript variable to ruby
  13. pass javascript variable to django url
  14. pass javascript variable to sql query
  15. pass javascript variable to asp classic
  16. pass javascript variable to python flask
  17. pass javascript variable to another html page
  18. pass javascript variable to django template
  19. pass javascript variable to mvc controller
  20. pass javascript variable between pages

I want to use jQuery to look for some text and it exists I want to hide it. So if : Yes exists it should be hidden. HTML: <div class="listing_detail col-md-4"><strong>Living Room:</...

I want to use jQuery to look for some text and it exists I want to hide it. So if : Yes exists it should be hidden. HTML: <div class="listing_detail col-md-4"><strong>Living Room:</...

  1. hide search text in datatable
  2. jquery datatable hide search text box
  3. hide text search

I have an image in the center of my webpage. Once the user scrolls and the image hits the top of the window, I am attempting to fix the image to the top of the page so that it scrolls with the page. ...

I have an image in the center of my webpage. Once the user scrolls and the image hits the top of the window, I am attempting to fix the image to the top of the page so that it scrolls with the page. ...

I want to set date and time to 2016-05-11T00:00:00.000Z var date = new Date(2016,4,12,0,0,0,0); but instead of showing Date 2016-05-11T00:00:00.000Z its giving Date 2016-05-11T19:00:00.000Z I want ...

I want to set date and time to 2016-05-11T00:00:00.000Z var date = new Date(2016,4,12,0,0,0,0); but instead of showing Date 2016-05-11T00:00:00.000Z its giving Date 2016-05-11T19:00:00.000Z I want ...

  1. javascript setting date
  2. javascript setting date format
  3. javascript date setting time zone
  4. javascript date setting time
  5. javascript datepicker setting date