Working on .net Core application. I have a button against each Client on by Clients screen. On click of button, I need a Modal dialog. The click event isnt getting fired, not sure why.

//Page html

<div id="businesses">
    <h3>List of all Businesses</h3>
    <div id="businessesTable">
        <table class="table table-condensed" id="businessIndexTable">
            <thead>
                <tr>
                    <th>Name </th>
                    <th>Logo </th>
                    <th>Phone</th>
                    <th>Email </th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var client in Model.Clients)
                {
                    <tr>
                        <td>@client.Name</td>
                        <td class=""> <img src="@client.LogoUrl" class="img-rounded" height="100" width="100" /> </td>
                        <td>@client.Phone</td>
                        <td>@client.Email</td>
                        <td><button id="btnCalcVS" class="btn btn-success" type="button"> Calculate Validator Score</button></td>
                    </tr>
                }
            </tbody>
        </table>
    </div>

//Modal dialog that should open when user clicks on "btnCalcVS"

 <div class="modal" id="calculateVSModal" role="dialog" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">
                        x
                    </button>
                    <h4 class="modal-title">Calculate Validator Score: Client Name</h4>
                </div>
                <div class="modal-body">
                    <form role="form" id="formCalculateVS">
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="Question" id="question" />
                        </div>
                        <div class="modal-footer">
                            <button type="button" data-dismiss="modal" class="btn btn-default">Close</button>
                            <button type="button" class="btn btn-success" id="calcVSScore">Calculate</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

//Jquery

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {      

        $(document).on("click", "btnCalcVS", function () {
            alert("We are here");
            $("#calculateVSModal").modal('show');
        });
    });
</script>

0 Answers