使用ajax发布页面后未加载日期时间选择器

时间:2013-11-19 15:05:10

标签: javascript jquery html ajax

任何人都可以帮助我

这是我的功能;

$(function () {
    $("#datepicker").datepicker({
        minDate: 0,
        onSelect: function (theDate) {
        },
        beforeShow: function () {
            $('#ui-datepicker-div').css('z-index', 9999);
        },
        dateFormat: 'mm/dd/yy'
    });
});

这是我的HTML

<div class="add-ctct-activity-date-time">
    <h4>Date</h4>
    <div>
        <input type="text"  id="datepicker" name="datepicker" class="add-ctct-activity-date-textbox" style="width:141px"/>
        <span style="position: relative; top: -7px; right: 43px;" class="add-ctct-activity-date-icon"></span>
    </div>
    <span><div id="WarningAddDate" class="textbox-warning-div-date"></div></span>
</div>

单击文本框时,datepicker第一次显示正常。但是,在使用ajax保存页面后,日期时间选择器未显示。但它在页面加载后显示。

这是ajax代码:

function SaveEditActivity(strdata, strActId, ActionResult) {
            $.ajax({
                type: 'Get',
                url: ActionResult,
                data: { Strdata: strdata, StrActId: strActId },
                success: function (data) {
                    $("#divActivtyShow").html(data);
                    $("#divActivityMenu").show();
                    if (ActionResult == "ComprehensiveAddNewActivity")
                        $('#SpanAddNewActivity').show();
                    $(".success-validate-msg").attr('style', 'display:block');
                    $(".success-validate-msg").html("Great! Contact Updated succussfully");
                },
                error: function (xhr, textStatus, errorThrown) {
                    alert(xhr.responseText);
                    $(".error-validate-msg").attr('style', 'display:block');
                    $(".error-validate-msg").html("Oops! Contact not updated.");
                }
            });
        }

使用Jquery我调用了ajax函数:

$('#divSaveActivitySaveAddNew').click(function () {
            if (!ValidateAddNewActivityFields()) {
                return false;
            } else {
                var Ischecked = "0";
                if ($("input[name=chckRemainder]:Checked").val() == "on")
                    Ischecked = "1";
                var strdata = $('#txtsummary').val() + "##$##" + $('#txtdetails').val() + "##$##" + $('#txthours').val() + ":" + $('#txtminutes').val() + " " +     $('#txttime').val() + "##$##" + Ischecked + "##$##" + $('#datepicker').val();
                var strActId = "";
                SaveEditActivity(strdata, strActId, "ComprehensiveAddNewActivity");
            }
        });

这是保存按钮

<div id="divComprehensiveEditAddNew" class="m-top" style="display:none">
    <span id="divSaveActivitySaveAddNew" class="blue-btn small-btn">Save</span><span id="btnActivityCancel" class="blue-link"><a href="#"     class="m-left">Cancel</a></span>
 </div>

0 个答案:

没有答案