Modal bootstrap

Asked

Viewed 436 times

2

I’m building a mobile app using Asp.net (aspx) and modal bootstrap. The purpose of this modal is to fill in a label with the information contained in the href "date-mark" attribute that triggers this modal. When the modal is triggered on the first try the label is not being filled in. The label is being filled only on 2nd modal opening attempt after myButton "Yes" has been clicked on 1st try.

//acionamento
<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>
  • But what problem exactly are you having?

  • The label is being filled only after the modal was first opened and the Button "Yes" has been clicked, that is, the label is being filled only when the modal is triggered in the 2nd opening attempt. At the first opening attempt the label is not being filled in.

  • I discovered the problem. I was using a Scriptmanager component in body. I took out the Scriptmanager component and the problem is over.

  • Great! congratulations, if you want it yourself can post here the solution to help if someone else has the same problem.

1 answer

0

I discovered the problem. I was using a Scriptmanager component in body. I took out the Scriptmanager component and the problem is over.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.