Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Clean way to set all forms to pristine status
Message
 
 
À
Tous
Information générale
Forum:
AngularJS
Catégorie:
Codage, syntaxe et commandes
Titre:
Clean way to set all forms to pristine status
Divers
Thread ID:
01657612
Message ID:
01657612
Vues:
50
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform