locked
the click event in JavaScript fired multiple time in asp.net MVC by partial view RRS feed

  • Question

  • User1589968622 posted

    In main page I'm attaching partial view and adding their back click event code that are same for main back, but when multiple time going to partial page and coming back to main page  when  I click back button repeatedly back event fired their how many time I visited partial view, how I resolve this issue.

    <html>

        <div id="divCAForm">
            <header id="homeHeader">
                <table style="width: 100%;">
                    <tr>
                       
                    </table>
                </div>
            </footer>*@
    }
    <div id="divCAConfirm" style="display:none;">

    ajax call:-

     $.ajax({
                contentType: "application/json; charset=utf-8",
                url: "/ConsumerAffairs/Home/ConfirmCADetail",
                data: (DescriptionInfoData),
                dataType: "html",
                success: showCAListResponse
            });

    function showCAListResponse(result, data) {
        $("#hdnstepno").val("4");
        $("#divCAConfirm").empty();
        $("#divCAConfirm").html(result);
        $("#divCAForm").hide();
        $("#divCAConfirm").show();
        Step4();
        $("#IsConfirm").val(true);
        BackButtonEventConfirm();
        GetNameOfUploadFile();
        liDownload();
    }

    //this code event fire multiple times when click back button

    function BackButtonEvent() {
        $('.back-icon').off('click').on('click', function (e) {

    //code

    // this event fired multiple times when click back button from main page

    })

    }

    Friday, April 9, 2021 7:04 AM

All replies

  • User475983607 posted

    anil bhadke

    I click back button repeatedly back event fired their how many time I visited partial view, how I resolve this issue.

    As far as I can tell your code is functioning as expected.  The design executes the AJAX function each time the content loads in the browser. 

    Is there anyway you can share code the community can actually run?  The code you've shared is rather confusing.

    Friday, April 9, 2021 10:06 AM