Delete query didn't fired on 1st time,it fired

2019-09-01 02:05发布

So here is the screen shot i have, i implemented workorder reject functionality, now when i click on cross button it open an iframe ask me to input some remark, and simply clicking on red button work orded rejected and its status changed accordingly. Everything is working fine, but the problem is when first time i performd this operation changes not reflected, after checking log i realized that query isn't fire.

enter image description here enter image description here

when 2nd time i again performed the same, it deletes the workorder, when again checking log, so my query is printed

sometimes it will take 3 attempt to delete the record. I can't figured out is this JS problem? because "closing an iFrame and redirect to the list I implemented an hour ago." here is the source code below

            <f:form action="${baseUrl}save_reject_status/${woSpIdEnc}" method="post" command="WorkOrderSp" id="workOrder" class="form-wizard validate" onsubmit="manageService()">



           <input type="hidden" name="woSpIdEnc"/>
            <div class="form-group"> 
                <label class="col-sm-2 control-label" for="field-5" style=" margin-top: 23px;">Remark<span style="color:#D50000">*</span></label> 
                <div class="col-sm-12"> 
                    <f:textarea path="rejectRemark" class="form-control autogrow" cols="5" id="field-5" required="required" placeholder="Let us know the reason behind rejection" style="margin-bottom:12px; height: 200px" />
                </div> 
                <div class="panel-footer" style="height:320px;">
                    <input type="submit" class="btn btn-danger pull-left no-margin" id="saveBtn" value="Reject Work Order" onclick="return confirm('Are you sure to Verify the Contractor.');">
                </div>

            </div>
        </f:form>

    <script>function manageService() {
            window.top.location.href = '../detail';
            parent.$.colorbox.close();
            return true;

        }
</script>

Now it perform all the required operation it closes the iframe as well as it also landing in the same page..but but workorder isn't deleted in first time. i am again performing the same and it worked!! sometimes it takes 3 steps to achieve the same. I want it to perform in the single shot.

1条回答
做个烂人
2楼-- · 2019-09-01 02:35

It is necessary first post the form request. You can try do this with jquery

<f:form action="${baseUrl}save_reject_status/${woSpIdEnc}" method="post" command="WorkOrderSp" id="workOrder" class="form-wizard validate" onsubmit="manageService(this);return false;">
    <!-- the form body -->
</f:form>

<script>
function manageService(form) {
  $(form).submit().success(function(){
    parent.$.colorbox.onClose = function(){window.top.location.href = '../detail';};
    parent.$.colorbox.close();
  });
}
</script>
查看更多
登录 后发表回答