javascript - Update a row in Parse.com -
what have when edit button clicked values in 2 input fields create new row , old row dropped.below code used want original row updated , not deleted. live example of how using code below works.
editbtn.onclick = function () { alert("edit btn"); alert(name.value + " " + lname.value); contact.save(null, { success: function (contact) { contact.set("firstname", name.value); contact.set("lastname", lname.value); contact.save(); object.destroy({ success: function (myobject) { alert("destroy"); location.reload(); }, error: function (myobject, error) { alert("error: " + error.code + " " + error.message); } }); } }); }
just clarify want update rows not create new 1 while deleting old one.
edit: link above question asked in parse forums.
edit: more information added in link reply comment.
edit: added this code editing first name ("newfname") wont update last name ("newlname").
editbtn.onclick = function () { var query = new parse.query(contact); query.equalto("lastname", newlname.value); query.first({ success: function (contact) { contact.save(null, { success: function (contact) { contact.set('firstname', newfname.value); contact.set('lastname', newlname.value); contact.save(); location.reload(); } }); } }); }
where have query.equalto("lastname", newlname.value), tried put in objectid i.e. (query.equalto("objectid"); didn't work me.
any ideas?
thomas
i managed updating code.
editbtn.onclick = function () { var query = new parse.query(contact); query.equalto("objectid", object.id); query.first({ success: function (contact) { contact.save(null, { success: function (contact) { contact.set("firstname", newfname.value); contact.set("lastname", newlname.value); contact.save(); location.reload(); } }); } }); }
Comments
Post a Comment