如何重置模态窗口上的数据打开?

时间:2015-07-14 19:37:30

标签: angularjs kendo-ui

我有趣的情况每当我打开模态窗口时,我正在重置下面字段的值,但是如果你选择值2,3次并用' x'来关闭模态。选择字段中保留一些时间值。我不知道为什么会发生任何想法?

main.html中

<form name="addChallengeForm" id="addChallengeForm" novalidate  ng-controller="challengesCtrl" class="border-box-sizing">
<div class="modalForm" disable-control-point="CHALLENGES_EDIT">
        <div class="row" ng-show="editMode">
                <div class="form-group col-md-12 fieldHeight">
                    <label for="originatingGroup" class="required col-md-4">Challenge Id:</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" id="challangeId" 
                            ng-model="challengesDTO.riskAssessmentChallengeKey" name="challangeId" readonly="readonly">
                    </div>
                </div>
        </div>
        <div class="row">
                <div class="form-group col-md-12 fieldHeight">
                    <label for="originatingGroup" class="required col-md-4">Originating group:</label>
                    <div class="col-md-8">
                        <select 
                            kendo-drop-down-list
                            data-text-field="'text'"
                            data-value-field="'id'" name="originatingGroup"
                            k-option-label="'Select'" ng-model-options="{updateOn: 'blur'}"
                            ng-model="challengesDTO.originatingGrpLkupCode"
                            k-data-source="challengeGroupOptions"
                            id="originatingGroup" required>         
                        </select>   
                        <p class="text-danger" ng-show="addChallengeForm.originatingGroup.$touched && addChallengeForm.originatingGroup.$error.required">Originating group is required</p>
                    </div>
                </div>
        </div>
        <div class="row">
                <div class="form-group col-md-12 fieldHeight">
                    <label for="challangeCreatedBy" class="col-md-4">Challenge created by:</label>
                    <div class="col-md-8">
                    <input type="text" class="form-control" id="challangeCreatedBy" 
                            ng-model="challengesDTO.initByWorker" name="challangeCreatedBy"> 
                    </div>
                </div>
        </div>
        <div class="row">
                <div class="form-group col-md-12">
                    <label for="challangeDes" class="required col-md-4">Description of challenge:</label>
                    <div class="col-md-8">
                        <textarea rows="4" class="form-control"
                                            name="challangeDes" id="challangeDes"
                                            ng-model="challengesDTO.challengeDescription" required
                                            placeholder="Description of challenge"  ng-model-options="{updateOn: 'blur'}">
                            </textarea>
                            <p class="text-danger" ng-show="addChallengeForm.challangeDes.$touched && addChallengeForm.challangeDes.$error.required">Description of challenge is required</p>
                    </div>
                </div>
        </div>

        <div class="row">
                <div class="form-group col-md-12">
                    <label for="themesList" class="required col-md-4">Themes:</label>
                    <div class="col-md-8">
                        <select class="multiselect" kendo-multi-select="themes"
                            k-options="challengThemesOptions" data-text-field="'text'"
                            data-value-field="'id'" name="themesList" 
                            ng-model="challengesDTO.themesKyList" required
                            k-data-source="challengThemesDataSource"
                            id="themesList"></select>
                            <p class="text-danger" ng-show="addChallengeForm.themesList.$touched && addChallengeForm.themesList.$error.required">Theme(s) is required</p>
                    </div>
                </div>
        </div>
        <div class="row">
                <div class="form-group col-md-12 fieldHeight">
                    <label for="ownerOrPreparer" class="col-md-4">RCSA Preparer 
                            Responding to Challenge:</label>
                    <div class="col-md-8">
                        <input type="text" class="form-control" id="ownerOrPreparer" 
                            ng-model="challengesDTO.challengeResponseWrk"
                            name="ownerOrPreparer" readonly="readonly" > 
                    </div>
                </div>
        </div>
        <div class="row" ng-show="editMode">
                <div class="form-group col-md-12">
                    <label for="responseComment" class="col-md-4">RCSA Preparer Response:</label>
                    <div class="col-md-8">
                        <textarea rows="4" class="form-control"
                                            name="responseComment" id="responseComment"
                                            ng-model="challengesDTO.challengeResponseComment"
                                            placeholder="RCSA Owner/Preparer Response">
                            </textarea>
                    </div>
                </div>
        </div>
        <div class="row" ng-show="editMode">
                <div class="form-group col-md-12 fieldHeight">
                    <label for="outcomeResolution" class="col-md-4">Outcome/Resolution:</label>
                    <div class="col-md-8">
                        <select 
                            kendo-drop-down-list
                            data-text-field="'text'"
                            data-value-field="'id'" name="outcomeResolution"
                            k-option-label="'Select'" ng-change="mandatoryEscalation()"
                            ng-model="challengesDTO.challengeDesLkupCode"
                            k-data-source="challengOutComeOptions"
                            id="outcomeResolution" >            
                        </select>   
                    </div>
                </div>
        </div>
        <div class="row" ng-if="editMode && showEscalation" disable-control-point="CHALLENGES_EDIT">
            <div class="form-group col-md-12 fieldHeight">
                <label for="requireEscalation" class="required col-md-4">Did the challenge 
                    require escalation to be resolved?:</label>
            <div class="col-md-8">
                <select kendo-drop-down-list k-data-text-field="'text'"
                    k-option-label="'Select'" k-data-value-field="'id'"
                    k-options="escalationDataSource" name="requireEscalation" 
                    ng-model="challengesDTO.esclRqrFlag" required
                    id="requireEscalation" ng-model-options="{updateOn: 'blur'}"></select>
                    <p class="text-danger" ng-show="addChallengeForm.requireEscalation.$touched && addChallengeForm.requireEscalation.$error.required">Challenge escalation is required</p>
            </div>
        </div>
        </div>
    </div>
        <div class="modal-footer">
            <button class="btn btn-primary pull-right" ng-disabled="addChallengeForm.$invalid" ng-click="submit()" require-control-point="CHALLENGES_ADD,CHALLENGES_EDIT">Save</button>
        </div>
    </form>

main.js

 $scope.challengesDTO = {};
  $scope.riskAssessmentDTO={
          firstName: '',
          lastName: '',
          emailId: '' ,
          nbkId: ''  
  };
  $scope.$on('kendoRendered', function() {
    rcsaAssessmentFactory.getThemeOptions().then(function(res){ 
      $scope.challengThemesOptions.dataSource = new kendo.data.ObservableArray({data: res.data});
    });
  });

     $scope.$on('addChallenge', function (s,id,opCheckList,checklistSessionKey){
        $scope.addChallengeForm.originatingGroup.$setUntouched();
        $scope.addChallengeForm.challangeDes.$setUntouched();
        $scope.addChallengeForm.themesList.$setUntouched();
        $scope.editMode = false;
          $scope.clearFields = clearForm();
          if($rootScope.user && $rootScope.user.customUserDetails){
              $scope.challengesDTO.initByWorker= $rootScope.user.customUserDetails.workFullName;
          }
          rcsaAssessmentFactory.getAssessmentPreparerInfo(id).then(function(response){
                $scope.riskAssessmentPreparer= response.data;   
                $scope.challengesDTO.challengeResponseWrkKey = $scope.riskAssessmentPreparer.rcsaPreparerWorkerKey;
                $scope.challengesDTO.challengeResponseWrk = $scope.riskAssessmentPreparer.rcsaPreparerWorker;
            });
            $scope.riskAssessmentDTO.riskAssessmentKey = id;
            $scope.challengesDTO.addChlngToChklst=opCheckList;
            $scope.challengesDTO.riskAssessmentChecklistSessionKey=checklistSessionKey;
            $scope.viewChallengeWin.open().center();
            $scope.submit = function(){
              rcsaAssessmentFactory.saveChallenge($scope.challengesDTO,id).then(function(){
                $scope.viewChallengeWin.close();
                $scope.$emit('refreshChallengeGrid');
                $scope.addChallengeForm.$setPristine();
                $scope.clearFields = clearForm();
              });
            };

          });

         var clearForm = function(){
           $timeout(function () { 
             $scope.challengesDTO = {
                     themesKyList: null
             };
           });
             $scope.challengeGroupOptions = kendoCustomDataSource.getDropDownDataSource('RA_ASES_CHLNG_GRP');
             $scope.challengThemesDataSource = kendoCustomDataSource.getDropDownDataSource('RA_CHLNG_THEME');
             $scope.challengOutComeOptions = kendoCustomDataSource.getDropDownDataSource('RA_CHLNG_OUTCOME');
             $scope.riskAssessmentDTO={
                      firstName: '',
                      lastName: '',
                      emailId: '' ,
                      nbkId: ''  
              };
         };

0 个答案:

没有答案