dimanche 10 juillet 2016

Ember js form retains old values

I tried other answers here on SO but none of them helped.

app/routes/card/new.js

actions: {
  save(title, description) {
    const newCard = this.get('store').createRecord('card', { title, description } );
    newCard.save().then((card) => {
      this.transitionTo('card.card', card);
    });
  }
}

For the view, I've:

app/templates/card/new.hbs

<form>
  <fieldset class="form-group">
    <label for="card-title">Card Title</label>
    
    <small class="text-muted">Give your card a nice title</small>
  </fieldset>

  <fieldset class="form-group">
    <label for="card-description">Card Description</label>
    
    <small class="text-muted">Describe your card</small>
  </fieldset>

  <div class="btn-group" role="group" aria-label="Save or Cancel your card">
    <button  class="btn btn-secondary">Save</button>
    <button  class="btn btn-danger">Cancel</button>
  </div>
</form>

When I create a card, it works fine but when I again try creating a new car, the form retains the old values which disappears on refresh.




Aucun commentaire:

Enregistrer un commentaire