从Bootstrap模态获取价值并返回调用函数

时间:2020-07-06 23:38:08

标签: javascript jquery bootstrap-modal

我有一个js函数可以打开引导程序模式。引导程序模式具有日期选择器控件。我想获取选定的日期,并将此值返回到打开引导程序模式的js函数。问题是一旦代码执行了引导程序模版...它将继续在函数getDate和doStuff中执行,并且不等待引导程序模版的结果。

请帮助。谢谢

function getDate() {
        var sidate;
        $("#myDateModal").modal();

        $('#dateOkBtn').click(function () {
            var datepicker = $find("<%= rdDate.ClientID %>");
            var chosenDate = datepicker.get_selectedDate().format("MM/dd/yyyy");
            sidate = chosenSIDate;

        });

        return sidate;
    }
    
    function dostuff() {
       var mydate;    
       mydate = getSelectedDate();       
     --do more stuff with mydate             
    }
    
    
<div class="modal" id="myDateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="z-index: 100000" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog modal-md" role="document">
        <div class="modal-content">
            <div class="modal-header modal-header-primary">
                <h3 class="modal-title" id="modalTitle">Birth Date</h3>
            </div>
            <div class="modal-body">
                <telerik:RadDatePicker ID   ="rdDate" runat="server" ZIndex="500000">
                    <DateInput runat="server" DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/dd/yyyy"  />
                </telerik:RadDatePicker>
            </div>
            <div class="modal-footer">
                <button id="dateOkBtn" class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>
                <button id="dateCloseBtn" class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
            </div>
        </div>
    </div>
</div>

0 个答案:

没有答案
相关问题