vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 403 forks source link

Display data from database when in edit mode #566

Closed jawizie closed 7 years ago

jawizie commented 7 years ago

Im trying to figure out how i can view database data in edit form im using php for my backend

ckosloski commented 7 years ago

This is more of a stack overflow question or just searching for how to load a js object with ajax from php and then looking at the xeditable examples. Maybe something like. http://stackoverflow.com/questions/30606614/angularjs-update-database-using-x-editable

Please close.

jawizie commented 7 years ago

Thanks a lot still link helped

On Mon, Oct 31, 2016 at 4:41 PM, ckosloski notifications@github.com wrote:

This is more of a stack overflow question or just searching for how to load a js object with ajax from php and then looking at the xeditable examples. Maybe something like. http://stackoverflow.com/questions/30606614/angularjs- update-database-using-x-editable

Please close.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vitalets/angular-xeditable/issues/566#issuecomment-257311792, or mute the thread https://github.com/notifications/unsubscribe-auth/AWGPEY_mGG1Gpm2ahTmLNaWoeVCI5yItks5q5f4mgaJpZM4KlEkB .

ckosloski commented 7 years ago

OK, if my guidance has solved your issue, please close it.

jawizie commented 7 years ago

well i have managed to follow that http://stackoverflow.com/questions/30606614/angularjs-update-database-using-x-editable im realising i cannot retrieve data posted from the form

ckosloski commented 7 years ago

Can you explain your issue some more, I don't follow.

jawizie commented 7 years ago

i have managed to display data from my database in the text boxes(when i'm in edit mode) but i am unable to post edited form data to the database .

ckosloski commented 7 years ago

Are you getting an error?

jawizie commented 7 years ago

no im not getting an errorbecause no data is posted from the form.

app.controller('ProfileFormCtrl', function($scope, $http) { $scope.display = function () { $http.get('../../core/scripts/insert.php') .success(function(data) { $scope.users = data; }); }; $scope.updateUser = function() { document.getElementById("message").textContent = ""; var request = $http({ method: "post", url: '../../core/scripts/clone.php', data: { 'name' :$scope.x.name, 'surname' :$scope.x.surname, 'dob' : $scope.x.dob, 'phone' : $scope.x.phone, 'national_id' : $scope.x.national_id, 'city' : $scope.x.city, 'about' : $scope.x.about }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' } });

    request.success(function (data) {
        document.getElementById("message").textContent = "Post Successful"+data;
    });
}

});

< editable-text="x.name" e-name="name" ></> this is how i have named the textboxes

ckosloski commented 7 years ago
jawizie commented 7 years ago

< editable-form name="editableForm" ng-repeat="x in users" onaftersave="updateUser()">

  1. i call it when i initialize the form the value changes after i save but not in my database
ckosloski commented 7 years ago
jawizie commented 7 years ago

yes updateUser is being called it is posting blank field values from what i deduced after adding some fake values in my back end i ran the function and it posted.I think the major issue is in the naming convention for values posted from edit mode as they are passed through function

ckosloski commented 7 years ago

As I stated above, where is x defined. Did you see what the value of your x object was in your updatUser method.

jawizie commented 7 years ago

x is the value from ng-repeat="x in users" which is from my display() function and so in order for me to view the data in edit mode i had to maintain that value it is not defined in the script

ckosloski commented 7 years ago

Then you need to either pass x into your function or pass in an index number and use that to get the correct object from your list of users.

jawizie commented 7 years ago

Created the object data posting succesfully to database but can no longer view the data in edit mode .Object name is user ..using the same name for the display() function object causes a conflict and no data is posted capture