mardi 5 septembre 2017

Attempted to handle event `deleteRecord` on while in state root.loaded.updated.inFlight-someid>

The exact question wasn't asked before. I am getting both Warning and Uncaught Error as below:

enter image description here

I set firebase rules to:

{ 
    "rules": { 
       ".read": true, 
        ".write": true 
     } 
} 

Some of the code:

For edit form in templates/contacts folder (using editContact action):

//templates/contacts/edit.hbs
<form>
    <div class="form-group">
        <label>First Name</label>
        
    </div>
    <div class="form-group">
        <label>Last Name</label>
        
    </div>
    <div class="form-group">
        <label>Mobile No</label>
        
    </div>
    <div class="form-group">
        <label>Phone No</label>
        
    </div>
    <button  class="btn btn-primary">Edit Contact</button> 
</form>

For controller of edit:

//controllers/contacts/edit.js
import Ember from 'ember';

export default Ember.Controller.extend({
    actions: {
        editContact: function(id){
            var self = this;

            var firstName = this.get('firstName');
            var lastName = this.get('lastName');
            var mobile = this.get('mobile');
            var phone = this.get('phone');

            //Update Contact
            this.store.findRecord('contact', id,{ reload: true }).then(function(contact){
                contact.set('firstName', firstName);
                contact.set('lastName', lastName);
                contact.set('mobile', mobile);
                contact.set('phone', phone);

                // Save to Database
                contact.save();             

            }).then(function(){
                self.transitionToRoute('contacts');
            });
        }
    }
});

But it still didn't work. What could be the problem?




Aucun commentaire:

Enregistrer un commentaire