Modal opens only after clicking twice when submitted for the first time from a button

浪尽此生 提交于 2019-12-11 02:03:56

问题


I have a modal popup to be opened from a button click. Unfortunately, I'm able to see the popup only after clicking twice when it is submitted for the first time in the browser. But once the popup is opened and closed, I'm able to open the modal with a single click on the next attempts. The same happens if I refresh my browser. This looks strange. Any body can explain, why? I have the following code,

Button html:

<div><button class="btn btn-danger btn-sm" ng-disabled="{{update_problem_description_disabled}}" ng-click="siverifyAddReviewModal()"><i class="glyphicon glyphicon-edit"></i> Edit Review </button>
    </div>

Modal html:

<div class="modal-header container-fluid">

   {% include "siverify_modal_header.html" %}
</div>
<form class="well form-horizontal" name="addReviewForm">
   {% csrf_token %}
   <div id="form-modal-body" class="modal-body">
      {% verbatim %}
      <table class="table" style="width:90%">
          <tr>
              <th><label>Review Title/Purpose*</label></th></br>
                {% endverbatim %}

              <td><input type="text" class="col-md-10" maxlength="256" ng-model="arform.revtitle" value="arform.revtitle"  required/></td>

              <!--<td><input type="text" class="col-md-10" maxlength="256" ng-init="'{{reviewtit}}'" ng-model="arform.revtitle"  > {{reviewtit}} </td>-->

          </tr>
<div class="modal-footer">
      <button type="submit" class="btn btn-primary"
              ng-disabled="addReviewForm.$invalid || rev_submit_disabled"
              ng-click="addReview(arform)">Save</button>
      <button type="button" ng-click="cancel()"
              class="btn btn-small btn-warning">Cancel</button>
   </div>
 </form>

Modal function

$scope.siverifyAddReviewModal = function(wpts,mask,lyr,tech) {
        // function to open modal and link to Modal Controller

        $scope.addRevModal = function(wptSet) {
            context = $scope.get_problem_stmt_context(dtWorklist, context_getter);
            //console.log("dtw", dtWorklist);
            var modalInstance = $modal.open({
                backdrop: 'static',
                templateUrl: '{% url 'siverify_add_review' %}',
                controller: 'SiVerifyAddReviewController',
                resolve:{
                        r_header: function(){ return wptSet; },
                        context: function(){ return context; }
                }
            });
           modalInstance.result.then(function () {
                datatable_worklist.refresh();
                $log.info('Modal success');

                //console.log(msg);
                }, function () {
                    $log.info('Modal dismissed at: ' + new Date());
            });
        };
        //End:function to open modal and link to Modal Controller

来源:https://stackoverflow.com/questions/40358942/modal-opens-only-after-clicking-twice-when-submitted-for-the-first-time-from-a-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!