how to make angular-xeditable edit state always enabled
Asked Answered
B

4

10

I am using angular-xeditable to edit elements within a form. I would like to have all the elements in "editable" mode at all times, e.g. no "edit" button needs to be pushed before the user starts editing.

I have been trying to use the $show() in my controller to enable the elements in the form, however it seems like the elements goes into viewing state again for example when using "onaftersave" when trying to save the values etc.

How do I do in order to always be in edit mode where the user never needs to enable editing in order to start editing the values?

Bihari answered 23/9, 2014 at 6:18 Comment(0)
A
7

Possibly try adding shown=true in your html:

<form editable-form shown="true">
Apomixis answered 16/10, 2014 at 15:22 Comment(0)
S
5

I had this same problem. Even when trying to $show() the form again at the end of my onaftersave function it still wouldn't work. I suspect the visibility is being hidden after the onaftersave function runs but I didn't actually check if that's the case. Here's how I got around it:

$scope.$watch('yourFormName.$visible', function() {
    $scope.yourFormName.$show();
});

Now whenever the form visibility changes to hidden, it will just show it again regardless of when it changed.

Shalom answered 10/10, 2014 at 16:31 Comment(2)
hey tcox, I am facing same issue, I always want table to remain in editable mode. I tried your way but when I call $scope.form.profileform.$visible=true; or $scope.form.profileform.$show(); it says undefined. my form name is name="form.profileform". can you please helpCephalalgia
I'm not sure if you have to say $scope.form.profileform, try just $scope.profileformShalom
F
1

If your form is already open, and you just want to keep it open after submitting, you can do this:

<form editable-form name="MyForm" onbeforesave="saveMyData()" onaftersave="keepFormOpen()">

and the function keepFormOpen() would look something like this:

$scope.keepFormOpen = function() {
    return "fake error message";
}

What this does is essentially gives the form a fake error message after you have already saved your data. This fake error message will interrupt the forms closing process, but since it was called after you already saved your data, it won't affect the previous submit.

Festschrift answered 14/10, 2014 at 21:30 Comment(1)
Glad I could help! Don't forget to accept it as an answer if it worked for you ;)Festschrift
B
0

To really keep open the form we can do the following:

<form editable-form name="MyForm" onbeforesave="saveMyData()" onhide="MyForm.$show()">
Barre answered 18/10, 2016 at 2:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.