Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim Brooks 27 posts 79 karma points
    Nov 25, 2014 @ 23:38
    Tim Brooks
    0

    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.

    enter image description here

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 26, 2014 @ 06:14
    Jan Skovgaard
    0

    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

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Nov 27, 2014 @ 17:53
    Andy Butland
    1

    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

  • Tim Brooks 27 posts 79 karma points
    Dec 05, 2014 @ 23:10
    Tim Brooks
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft