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

Copy value using change affects all time fields when one value is changed #213

Open
MonikaHencekova opened this issue Sep 12, 2017 · 0 comments

Comments

@MonikaHencekova
Copy link

MonikaHencekova commented Sep 12, 2017

I have a form in MVC5 which is rendered dynamically with repeating 4 fields. One of these fields is time picker.
What I want to achieve: Select time in first time field and copy this value to others time fields using change and after value in other time fields is changed these fields needs to be still editable independently on others, so when I decide to change value in 3rd time field it can not affect values in 1st and 2nd field only in the 3rd.
Do you know how can I achieve required functionality?
My input field:

@Html.TextBoxFor(model => model.MyModels.Model[i].Time,
                        new
                        {
                            @class = "form-control",
                            ng_Model = "Model_Time" + (i + 1),
                            change = "copyTime(" + (i + 1) + ")",
                            moment_picker = "Model_Time" + (i + 1),
                            format = "LT",
                            locale = "nl",
                            ng_model_options = "{ updateOn: 'blur' }",
                            set_on_select = true
                        })

My ng_change function:

  $scope.copyTime = function (index) {        
        console.log("Check if copy function is called");
        $scope.Model_Time2 = $scope.Model_Time1;
        $scope.Model_Time3 = $scope.Model_Time1;
        $scope.Model_Time4 = $scope.Model_Time1;
        $scope.Model_Time5 = $scope.Model_Time1;
};
@MonikaHencekova MonikaHencekova changed the title Copy time value with ng_change doesn't work Copy value using change affects all time fields when one value is changed Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant