第一次点击后,日历字段不会预先填充

时间:2019-04-01 13:51:19

标签: php jquery datebox

代码是关于一个链接的,该链接在页面重新加载后第一次单击时会用日期和时间填充输入字段,但最初在第一个弹出窗口之后,单击链接不会在日期中填充日期和时间,直到我再次刷新页面..代码使用Jtstage用户界面中的日期框

我在第二次单击时在后台收到此错误。

  

未捕获的错误:无法在日期框之前调用方法   初始化;尝试调用方法“ setTheDate”

<script type="text/javascript" >
function bindPage() {
    var $ = jQuery;
    if (typeof (jQuery.jtsage) == 'undefined' || typeof (jQuery.jtsage.datebox) == 'undefined') {
        setTimeout(function () { bindPage() }, 100.);
    } else {
        jQuery('#emailMessage').hide();
        jQuery('#txtStartDate').datebox('setTheDate', "<?=date("d M Y", time() - (86400 * 7))?>");
        jQuery('#txtEndDate').datebox('setTheDate', "<?=date("d M Y", time() + (86400 * 7))?>");
}

HTML

<div class="row-fluid center">

    <div class="span12 xspan12 subtleText">
        Select the date range:
    </div>
    <div class="span8 xspan12" style="float:none;margin-left:auto;margin-right:auto;padding-left:15px;padding-right:15px;">

        <div class="span12" style="margin-bottom:20px;">
            <div class="span12 xspan12 left">
                <label for="txtStartDate">
                    From:
                </label>
            </div>
            <div class="span12 xspan12 left" style="">
                <input id="txtStartDate" type="text" class="span12 xspan12" data-role="datebox"
                       data-options='{"mode":"calbox","overrideDateFormat": "%d %b %Y", "beforeToday":"True", "notToday":"True","closeCallback":"linker", "closeCallbackArgs":["txtEndDate"] }' style="cursor:pointer;">
            </div>
        </div>
        <div class="span12 xspan12 left">
            <label for="txtEndDate">
                To:
            </label>
        </div>
        <div class="span12 xspan12 left" style="">
            <input id="txtEndDate" type="text" class="span12 xspan12" data-role="datebox" data-options='{"mode":"calbox","overrideDateFormat": "%d %b %Y"}' style="cursor:pointer;">
        </div>
    </div>
</div>
<div class="row-fluid center">

    <div class="span12 xspan12 subtleText">
        Select the date range:
    </div>
    <div class="span8 xspan12" style="float:none;margin-left:auto;margin-right:auto;padding-left:15px;padding-right:15px;">

        <div class="span12" style="margin-bottom:20px;">
            <div class="span12 xspan12 left">
                <label for="txtStartDate">
                    From:
                </label>
            </div>
            <div class="span12 xspan12 left" style="">
                <input id="txtStartDate" type="text" class="span12 xspan12" data-role="datebox"
                       data-options='{"mode":"calbox","overrideDateFormat": "%d %b %Y", "beforeToday":"True", "notToday":"True","closeCallback":"linker", "closeCallbackArgs":["txtEndDate"] }' style="cursor:pointer;">
            </div>
        </div>
        <div class="span12 xspan12 left">
            <label for="txtEndDate">
                To:
            </label>
        </div>
        <div class="span12 xspan12 left" style="">
            <input id="txtEndDate" type="text" class="span12 xspan12" data-role="datebox" data-options='{"mode":"calbox","overrideDateFormat": "%d %b %Y"}' style="cursor:pointer;">
        </div>
    </div>
</div>

0 个答案:

没有答案