Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Make parent form aware of child form ng-dirty state chan
Message
 
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01623431
Message ID:
01623504
Views:
32
>>>Didn't have time to look through all that but I see you are not using 'ng-form'
>>>From angular docs:
>>>
>>>"Nestable alias of form directive. HTML does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a sub-group of controls needs to be determined."
>>>
>>>If you're not using ng-form your fighting an uphill battle for no reason.
>>>Did you try my example ?
>>
>>I don't think in my case it's relevant if I am using form or ng-form for the main form container. I think I tried ng-form with the same result.
>>
>>The problem here is that my SelectView method seem to happen prior to the directive being hit. In other words, it looks like when I select a new row from the list, first my SelectView method is firing (and the form is obviously in the pristine state already) and then the directive checks for the form.$dirty state which is false at this moment.
>>
>>In other words, I added this code into my selectView method:
>>
>>
>>if ($scope.form && $scope.form.$dirty)
>>                {
>>                    $scope.selections.somethingChanged = true;
>>                }
>>
>>So, when I start from the General tab, change something and go to another tab, I can see that form.$dirty flag is properly set.
>>
>>But when I select the different row, this code is being executed first before the directive.
>>
>>So, it seems like my problem is that the directive fires after I already switched to a different row.
>>
>>I am thinking - may be I can try introducing that check from the directive inside the controller of the index page instead.
>
>Dunno. Seems to me your are making things hopelessly complicated when simple nested ng-forms should give you the result you need.
>Basically, I don't know what you are looking for that isn't covered by my example.

I am saying that the way events are firing are not working in our case. We have an index view with ui-view. In that new view which is the main container editForm we have tabs where each tab is supposed to open a new form using state. I showed the code used to activate each individual tab. The problem here is when we're trying to navigate to another row, the Cancel changes question is not presented. Tracing the code I can see that the directive's code is happening after the switch to another Id and general tab already happened.

That's the problem I (and prior to that my colleague before giving up) are trying to overcome.
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