Delete query didn't fired on 1st time,it fired after 2nd or 3rd time

强颜欢笑 提交于 2019-12-24 18:17:31

问题


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.

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:


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>


来源:https://stackoverflow.com/questions/48165708/delete-query-didnt-fired-on-1st-time-it-fired-after-2nd-or-3rd-time

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