{"id":1478,"date":"2022-08-30T15:16:52","date_gmt":"2022-08-30T15:16:52","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/23\/how-to-update-record-in-local-storage-using-ember-data-and-localstorage-adapter-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:52","modified_gmt":"2022-08-30T15:16:52","slug":"how-to-update-record-in-local-storage-using-ember-data-and-localstorage-adapter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-to-update-record-in-local-storage-using-ember-data-and-localstorage-adapter-collection-of-common-programming-errors\/","title":{"rendered":"How to update record in local storage using ember data and localstorage adapter?-Collection of common programming errors"},"content":{"rendered":"<p>I am new to emberjs and making one simple CRUD application. I am using ember data and localstorage-adapter to save record in local storage of browser.<\/p>\n<p>I am trying to update record using localstorage-adapter but it is throwing error.<\/p>\n<p>I have listed my code here :<\/p>\n<pre><code>updatecontact: function(){\/\/save data in local storage\n        var fname = this.obj_form_edit_data.get('cont_data.fname');\n        var lname = this.get('cont_data.lname');\n        var email = this.get('cont_data.email');\n        var contactno = this.get('cont_data.contactno');\n        var gendertype = ((this.get('isMale') == true) ? true : false);\n        var contactype = $(\".selectpicker\").val();\n        Grid.ModalModel.updateRecords({ \n          fname: fname,\n          lname: lname,\n          email: email,\n          contactno: contactno,\n          gendertype: gendertype,\n          contactype: contactype\n        });\n        this.get('store').commit();             \n    }\n<\/code><\/pre>\n<p>I am getting following error using above code :<\/p>\n<pre><code>Uncaught TypeError: Object function () {\nif (!wasApplied) {\n  Class.proto(); \/\/ prepare prototype...\n}\no_defineProperty(this, GUID_KEY, undefinedDescriptor);\no_defineProperty(this, '_super', undefinedDescriptor);\nvar m = meta(this);\nm.proto = this;\nif (initMixins) {\n  \/\/ capture locally so we can clear the closed over variable\n  var mixins = initMixins;\n  initMixins = null;\n  this.reopen.apply(this, mixins);\n}\nif (initProperties) {\n  \/\/ capture locally so we can clear the closed over variable\n  var props = initProperties;\n  initProperties = null;\n\n  var concatenatedProperties = this.concatenatedProperties;\n\n  for (var i = 0, l = props.length; i &lt; l; i++) {\n    var properties = props[i];\n\n    Ember.assert(\"Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.\", !(properties instanceof Ember.Mixin));\n\n    for (var keyName in properties) {\n      if (!properties.hasOwnProperty(keyName)) { continue; }\n\n      var value = properties[keyName],\n          IS_BINDING = Ember.IS_BINDING;\n\n      if (IS_BINDING.test(keyName)) {\n        var bindings = m.bindings;\n        if (!bindings) {\n          bindings = m.bindings = {};\n        } else if (!m.hasOwnProperty('bindings')) {\n          bindings = m.bindings = o_create(m.bindings);\n        }\n        bindings[keyName] = value;\n      }\n\n      var desc = m.descs[keyName];\n\n      Ember.assert(\"Ember.Object.create no longer supports defining computed properties.\", !(value instanceof Ember.ComputedProperty));\n      Ember.assert(\"Ember.Object.create no longer supports defining methods that call _super.\", !(typeof value === 'function' &amp;&amp; value.toString().indexOf('._super') !== -1));\n\n      if (concatenatedProperties &amp;&amp; indexOf(concatenatedProperties, keyName) &gt;= 0) {\n        var baseValue = this[keyName];\n\n        if (baseValue) {\n          if ('function' === typeof baseValue.concat) {\n            value = baseValue.concat(value);\n          } else {\n            value = Ember.makeArray(baseValue).concat(value);\n          }\n        } else {\n          value = Ember.makeArray(value);\n        }\n      }\n\n      if (desc) {\n        desc.set(this, keyName, value);\n      } else {\n        if (typeof this.setUnknownProperty === 'function' &amp;&amp; !(keyName in this)) {\n          this.setUnknownProperty(keyName, value);\n        } else if (MANDATORY_SETTER) {\n          Ember.defineProperty(this, keyName, null, value); \/\/ setup mandatory setter\n        } else {\n          this[keyName] = value;\n        }\n      }\n    }\n  }\n}\nfinishPartial(this, m);\ndelete m.proto;\nfinishChains(this);\nthis.init.apply(this, arguments);\n<\/code><\/pre>\n<p>} has no method &#8216;updateRecords&#8217;<\/p>\n<p>I am using following code to create new record which working fine :<\/p>\n<pre><code>savecontact: function(){\/\/save data in local storage\n        var fname = this.obj_form_edit_data.get('cont_data.fname');\n        var lname = this.obj_form_edit_data.get('cont_data.lname');\n        var email = this.obj_form_edit_data.get('cont_data.email');\n        var contactno = this.obj_form_edit_data.get('cont_data.contactno');\n        var gendertype = ((this.get('isMale') == true) ? true : false);\n        var contactype = $(\".selectpicker\").text();\n        Grid.ModalModel.createRecord({  \n          fname: fname,\n          lname: lname,\n          email: email,\n          contactno: contactno,\n          gendertype: gendertype,\n          contactype: contactype\n        });\n        this.get('store').commit(); \n    }\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-23 07:55:49. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am new to emberjs and making one simple CRUD application. I am using ember data and localstorage-adapter to save record in local storage of browser. I am trying to update record using localstorage-adapter but it is throwing error. I have listed my code here : updatecontact: function(){\/\/save data in local storage var fname = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1478","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1478"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1478\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}