Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When used in a form the form element is dirty onload #61

Closed
worldspawn opened this issue Dec 24, 2013 · 4 comments
Closed

When used in a form the form element is dirty onload #61

worldspawn opened this issue Dec 24, 2013 · 4 comments
Labels
Milestone

Comments

@worldspawn
Copy link
Contributor

Hi,

I have this
<div text-angular ng-model="item.description" id="description" name="description" required></div>

The trouble is that (my form is called create) create.description.$dirty is true as soon as the form loads. So when this thing loads it is somehow clearing the pristine flag. I make use of $dirty in my forms to hide validation errors until the user has a had a chance to interact with the field.

@worldspawn
Copy link
Contributor Author

I changed the following in my 2 seconds of testing it seems to have resolved it

scope.$watch('text', function(newValue, oldValue){
                scope.html = newValue;
                if(attrs.ngModel && newValue !== oldValue) ngModel.$setViewValue(newValue);
                scope.displayElements.forminput.val(newValue);
            });
            scope.$watch('html', function(newValue, oldValue){
                scope.text = newValue;
                if (attrs.ngModel && newValue !== oldValue) ngModel.$setViewValue(newValue);
                scope.displayElements.forminput.val(newValue);
            });

The change was adding the && newValue !== oldValue... sorry i'm on holiday and creating a PR atm is too hard :)

@SimeonC
Copy link
Collaborator

SimeonC commented Jan 10, 2014

Thanks for the Issue and the fix, it will be in a future version. I'm technically on holiday as well so it may be February before I get the next version out.

@worldspawn
Copy link
Contributor Author

Thanks, enjoy your break 😎

@worldspawn
Copy link
Contributor Author

Hey this seems to be fixed in master, just tried it out. Can close.

@SimeonC SimeonC closed this as completed Jan 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants