ember.js - How to update/edit record in emberjs? -


i have collected data fixture , displayed in form of table.

also,i have added 2 column 1 edit delete want edit specific row.

on click of edit have populated data on modal window 1 update button , want update changes on click of update.

here code : store :

grid.store = ds.store.extend({adapter: 'ds.fixtureadapter'}); 

router:

        grid.router.map(function () {       this.resource('mainview', { path: '/' });                            });       grid.mainviewroute = ember.route.extend({           model: function () {             return grid.modalmodel.find();           }     }); 

model :

    grid.modalmodel =  ds.model.extend({     fname: ds.attr('string'),     lname: ds.attr('string'),     email: ds.attr('string'),     contactno: ds.attr('string'),     gendertype: ds.attr('boolean'),     contactype: ds.attr('number') });  grid.modalmodel.fixtures = [                        {                          id: 1,                          fname: "sachin",                          lname: "gh",                          email: "gh",                          contactno: "4542154",                          gendertype: true,                          contactype: 1                        },                        {                          id: 2,                          fname: "amit",                          lname: "gh",                          email: "gh",                          contactno: "4542154",                          gendertype: true,                          contactype: 1                        },                        {                          id: 3,                          fname: "namit",                          lname: "gh",                          email: "gh",                          contactno: "4542154",                          gendertype: true,                          contactype: 1                        }                       ]; 

controller :

grid.mainviewcontroller = ember.arraycontroller.extend({     contentchanged: function() {         this.get('content').foreach(function(item){           var serializer = ds.restserializer.create();           var json_data = serializer.serialize(item);           console.log(json.stringify(json_data));         });       }.observes('content.@each'),     showmodal: function(){               $('#modal').modal();      },     showeditmodal: function(){         var rowindex_table = 1;         var contactype = 0;           var post = grid.modalmodel.find(rowindex_table);           var serializer = ds.restserializer.create();           var cont_edit_data = serializer.serialize(post);           console.log(json.stringify(cont_edit_data));            this.set('obj_form_edit_data.cont_data.fname', cont_edit_data["fname"]);             this.set('obj_form_edit_data.cont_data.lname', cont_edit_data["lname"]);             this.set('obj_form_edit_data.cont_data.email', cont_edit_data["email"]);             this.set('obj_form_edit_data.cont_data.contactno', cont_edit_data["contactno"]);             if(cont_edit_data["gendertype"] == true){                 this.set('male', true);                 $(".cssmale").addclass("active");             }else{                 this.set('female', true);                 $(".cssfemale").addclass("active");             }             $('.selectpicker').val(cont_edit_data['contactype']);             $('.selectpicker').selectpicker('render');             $('#editmodal').modal();     },     ismale: false,     isfemale: false,     obj_form_edit_data : ember.object.create({         cont_data:{             fname : "",             lname : "",             email : "",             contactno : "",             gendertype : "",             contactype : 0         }     }),          gendertype: function(){         this.set('ismale', !this.get('ismale'));     },     savecontact: function(){//save data in local storage         var fname = this.obj_form_edit_data.get('cont_data.fname');         var lname = this.obj_form_edit_data.get('cont_data.lname');         var email = this.obj_form_edit_data.get('cont_data.email');         var contactno = this.obj_form_edit_data.get('cont_data.contactno');         var gendertype = ((this.get('ismale') == true) ? true : false);         var contactype = $(".selectpicker").text();         //clear view first         this.set('obj_form_edit_data.cont_data.fname', '');         this.set('obj_form_edit_data.cont_data.lname', '');         this.set('obj_form_edit_data.cont_data.email', '');         this.set('obj_form_edit_data.cont_data.contactno', '');         this.set('ismale',false);         this.set('isfemale',false);         $('.selectpicker').val('0');         $('.selectpicker').selectpicker('render');          grid.modalmodel.createrecord({             fname: fname,           lname: lname,           email: email,           contactno: contactno,           gendertype: gendertype,           contactype: contactype         });         this.get('store').commit();      },     updatecontact: function(){         this.get('store').commit();     }   updatecontact used update record on click of update button throwing error  uncaught typeerror: object [object object] has no method 'commit' 

can tell me how update record in such case?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -