0

我创建了一个引导弹出窗口,其代码如下所示。现在我希望弹出框显示我在页面上单击的任何位置。我应该如何做到这一点?

目前它出现在点击“弹出链接”上。

请帮忙!

HTML:

<br>
<br>
<br>
<br>
<div class="container">
    <div class="span3">


        <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <a href="#" id="popover">the popover link</a>
        <!-- Changed the bootstrap css for popover maximum width to 800px from 276 px -->
        <div id="popover-head" class="hide"> Event | <a id="appointmentsInformationReference" href="#">Appointments</a> </div>

        <div id="popover-content" class="hide">

                <!-- form-horizontal .controls margin left changed from 180 to 0 px -->

                <form class="form-horizontal" style="margin-top: 15px">

                    <div class="control-group inline" >
                        <label class="control-label" style="width: 75px; text-align: left" for="dateAppointment">Date: </label>
                        <div class="controls pull-left" >
                            <input type="text" id="dateAppointment" placeholder="Date of Appointment">
                        </div>
                    </div>


                    <div class="control-group inline" >
                        <label class="control-label" style="width: 75px; text-align: left" for="namePatient">Name: </label>
                        <div class="controls pull-left" >
                            <input type="text" id="namePatient" placeholder="Name of Patient">
                        </div>
                    </div>

                    <div class="control-group inline">
                        <label class="control-label" style="text-align: left; width: 75px" for="locationAppointment">Where: </label>
                        <div class="controls pull-left">
                            <input type="text" id="locationAppointment" placeholder="Location">
                        </div>
                    </div>
                    <div class="control-group inline">
                        <div class="controls">
                            <button type="createAppointment" class="btn btn-block pull-left" style="width: 45%; margin-top: 10px">Create</button>
                            <button type="editAppointment" class="btn btn-block pull-right" style="width: 45%; margin-top: 10px">Edit</button>
                        </div>
                    </div>
                </form>

        </div>

        <div id="appointmentsInformationContent" class = "hide">
            <p> This is some information about the appointments </p>
        </div>
    </div>

Javascript:

<script>
 $(document).ready(

    $('#popover').popover({
        html : true,
        title: function() {
            return $("#popover-head").html();
        },
        content: function() {
            return $("#popover-content").html();
        },

        placement: 'top'
    }),

    $(document).on('click', '#appointmentsInformationReference', function()
    {
        alert('beep');
    })

 )

</script>
4

1 回答 1

-2

Bootstrap 的弹出窗口位置可以是一个函数,它(我猜)有一个事件参数,在控制台中记录它并查看它是否包含鼠标位置坐标。

placement: function(x) {
   console.log(x);
}
于 2013-08-22T09:14:08.103 回答