Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
By-passing $dirty check
Message
 
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01609780
Message ID:
01617460
Views:
32
Hi Viv,

Somehow this doesn't seem to work on one page. I am getting a message about Changes.

My directive is
(function () {
    'use strict';

    var app = angular.module('sysMgrApp');

    app.directive('noDirtyCheck', [function () {
        // Interacting with input elements having this directive won't cause the
        // form to be marked dirty.
        // http://stackoverflow.com/questions/17089090/prevent-input-from-setting-form-dirty-angularjs
        return {
            restrict: 'A',
           
            require: 'ngModel',
            link: function (scope, element, attrs, ctrl) {           

                element[0].focus(function () {
                    ctrl.$pristine = false;
                });
            }
        };
    }]);
})();
and the page has this control:
 <div class="col-lg-5 col-lg-offset-1">
                    <input class="form-control" type="text" ng-model="searchTerm" data-no:dirty-check ="true"
                    placeholder="@Labels.search" />
                </div>
when I type something in that control and inspect the element, I can see the ng-dirty class on it.

Do you see why it's not working in that form? The directive does seem to work OK in other forms.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform