Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Bootstrap Modal hide not working in partialview

I'm adding a button close that will close/hide the Modal diaglog when button is clicked. for some reason nothing is happening when the button is clicked. I assume that the modal id is not recognized after button is clicked. not sure what could be the correct approach?

<--Index.cshtml-->

<div class="form-button-action">
  <button type="button" class="btn btn-link btn-lg" id="Edit" onclick="Edit(@item.Id)">
      <a class="fas fa-pencil-alt" data-toggle="tooltip" data-placement="top" title="Edit Session"></a></button>
</div>

<div class="modal fade" id="myModalForm" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-body" id="myModalBodydiv" data-backdrop="static" data-keyboard="false">


            </div>
        </div>
       
    </div>
</div>

<script>
    var Edit = function (id) {
        $.ajax({
            type: "GET",
            url: "/Exposure/EditSession",
            data: { Id: id },
            success: function (response) {
                $("#myModalBodydiv").html(response);
                $('#myModalForm').modal({ backdrop: 'static', keyboard: false })
                $("#myModalForm").modal("show");
                $("#myModalForm").appendTo("body");
            }
        })
    }
</script>


<--partialView.cshtml-->
@model Insured

<div class="modal-header no-bd">
    <h1 class="fw-mediumbold">
        Title
    </h1>
    <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>


<div class="modal-footer no-bd">
    <button type="submit" class="btn btn-light" id="closeModal" data-dismiss="modal">Close</button>
</div>



<script>
    $("#closeModal").click(function () {
        $('#myModalBodydiv').modal('hide');
    });
</script>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!