how to make angular-xeditable edit state always enabled

馋奶兔 提交于 2019-12-04 02:27:36
bruce.donovan

Possibly try adding shown=true in your html:

<form editable-form shown="true">

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.

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.

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

<form editable-form name="MyForm" onbeforesave="saveMyData()" onhide="MyForm.$show()">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!