简体   繁体   中英

Bootstrap modal

I'm building a mobile application using asp.net (aspx) and modal bootstrap. The purpose of this modal is to fill a label with the information contained in the "data-marcacao" attribute of the href that triggers this modal. When the modal is triggered on the 1st attempt the label is not being filled. The label is being populated only in the 2nd attempt to open the modal after the "Yes" myButton has been clicked on the 1st attempt.

//triggered
<a href="#" data-toggle="modal" data-target="#myModal" data-marcacao="frase qualquer">

//modal
    <div class="modal fade" id="myModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                </div>
                <div class="modal-body">
                    <asp:Label ID="lblModalMarcacao" runat="server"></asp:Label>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-success btn-md" id="myButton">Sim</button>
                    <button class="btn btn-danger btn-md" data-dismiss="modal">Não</button>
                </div>
            </div>
        </div>
    </div>

//script
    <script type="text/javascript">
            $('#myModal').modal({ backdrop: 'static', keyboard: false });
            $('#myModal').modal('toggle');
            $('#myModal').modal('handleUpdate');

            $(document).ready(function () {
                $("a").on("click", function (e) {
                    e.preventDefault();
                    $('#lblModalMarcacao').text('Marcação: ' + $(this).attr("data-marcacao"));
                });
            });
    };
</script>

I discovered the problem. I was using a ScriptManager component in the body. I deleted the ScriptManager component and the problem is over.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM