Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clean way to set all forms to pristine status
Message
 
 
To
All
General information
Forum:
AngularJS
Category:
Coding, syntax & commands
Title:
Clean way to set all forms to pristine status
Miscellaneous
Thread ID:
01657612
Message ID:
01657612
Views:
49
Hi everybody,

This is the current setPristine method where I just added last 2 lines:
 DateTimePicker.prototype.setPristine = function () {
        if (this.form) {
            this.form.$setPristine();

            if (this.form.$$parentForm.$dirty) {
                this.form.$$parentForm.$setPristine();
            }
            if (this.form.$$parentForm.$$parentForm && this.form.$$parentForm.$$parentForm.$dirty) {
                this.form.$$parentForm.$$parentForm.$setPristine();
            }
        }
    };
I don't really like it. Is there a cleaner way to set everything to pristine from the bottom up?

Thanks a lot in advance.

UPDATE. Per suggestion in stackoverflow re-wrote the above as recursive function. Works quite nicely.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform