Disable the ng-dirty class being added on a dashboard tab
I'm attempting to remove the ng-dirty from a custom tab (and custom section) in my dashboard. I have a pulldown where I do some filtering based on the selection, but nothing needs to be saved so when the ng-dirty is applied, I'd like to remove it. Here is my controller function:
$scope.onFilterEditor = function() {
var id = $scope.selectedItem;
if (id == "all editors") {
id = "";
}
console.log($scope.reviewform);
//$scope.reviewform.$setPristine());
console.log(reviewform);
//reviewform.removeClass("ng-dirty");
$http.get('/umbraco/backoffice/People/articleapi/getall?editor=' + id).success(function (data) {
$scope.articles = data;
$scope.loading = false;
}).error(function (er) {
$scope.error = er + "An error has occured while loading reviews.";
$scope.loading = false;
});
};
console.log(reviewform) returns the form object, but $scope.reviewform is undefined. How can I get access to this to set form back to pristine? I believe part of the issue is that this form is nested in the main umbraco back office form. See the mark up in the image below.
A few weeks ago I added an AnguarJS directive to the code via a pull request that you can add to a form element to prevent it triggering a dirty state. It's used on the list view when you search (as without this you would get that "Something has changed, save or discard" message when you attempted to move to a new page in the back-office).
Not sure if you can access and make use that but you can see it used here and defined here.
Andy - that's it! Thank you very much. Just to be explicit, and save somone one click, I added these attributes to the field in question:
prevent-enter-submit no-dirty-check
This works well because I only have one field I'm worried about. I had gotten to the point where I just removed the class ng-dirty and added ng-pristine to every tag on the page and that didn't work either. But this solution did. Thanks again.
Disable the ng-dirty class being added on a dashboard tab
I'm attempting to remove the ng-dirty from a custom tab (and custom section) in my dashboard. I have a pulldown where I do some filtering based on the selection, but nothing needs to be saved so when the ng-dirty is applied, I'd like to remove it. Here is my controller function:
console.log(reviewform) returns the form object, but $scope.reviewform is undefined. How can I get access to this to set form back to pristine? I believe part of the issue is that this form is nested in the main umbraco back office form. See the mark up in the image below.
Hi Tim
Don't kow if this post from SO can help? http://stackoverflow.com/questions/12603914/reset-form-to-pristine-state-angularjs-1-0-x
Also see this fiddle http://jsfiddle.net/juurlink/FWGxG/7/
Hope this helps.
/Jan
A few weeks ago I added an AnguarJS directive to the code via a pull request that you can add to a form element to prevent it triggering a dirty state. It's used on the list view when you search (as without this you would get that "Something has changed, save or discard" message when you attempted to move to a new page in the back-office).
Not sure if you can access and make use that but you can see it used here and defined here.
Andy
Andy - that's it! Thank you very much. Just to be explicit, and save somone one click, I added these attributes to the field in question:
prevent-enter-submit no-dirty-check
This works well because I only have one field I'm worried about. I had gotten to the point where I just removed the class ng-dirty and added ng-pristine to every tag on the page and that didn't work either. But this solution did. Thanks again.
Tim
is working on a reply...