lundi 22 juin 2015

emberjs attributes not getting saved on form submit

I have this form in a component:

<form class="" {{action "saveEdit" on="submit"}}>
  {{input type="text" id="name"value=person.name  }}
  {{input type="date" id="dob" value=person.date_of_birth}}
  <button type="submit">Save</button>
</form>

When it gets submitted I user sendAction to send it to the route:

   saveEdit: function () {
      this.set("isEditing", false);

      this.sendAction("action", this.get("person"));
    } 

Where I save it:

saveEdit: function (person) {
      person.save();
    }

However, only the name gets saved,

This does not work:

  saveEdit: function () {
      this.set("isEditing", false);
      var dob= $("#dob").val();
      var person = this.get("person");
      person.set("date_of_birth", dob);
      this.sendAction("action", person);
    }

When I console.log the person object I get:

_data: Object
date_of_birth: null
id: "1"
name: "Joey"

The name updates but the date_of_birth gets set to null.

I don't understand why this is happening




Aucun commentaire:

Enregistrer un commentaire