0

I have 'jquery-1.12.4.js', 'jquery-ui-1.12.0.js' and my css in my shared layout.

I'm using jquery dialog to popup.

and I call my partial view and load it.

$element.dialog({
    autoOpen: false,
    width: wSize,
    height: hSize,
    resizable: true,
    draggable: true,
    title: dTitle,
    closeOnEscape: true,
    open: function (event, ui) {
        $(this).load(url);
    },

    close: function () {
        $(this).css("display", "none"); 
    }
});


$("#elementID").dialog("open");

In my server side..

public ActionResult stats(string sDate, string eDate, string Mode, int Id)
    {
        ...

        try
        {
            ...
            Model stats = GetDatabase

            ViewData["StartDate"] = sDate;
            ViewData["EndDate"] = eDate;

        }
        catch(Exception ex)
        {
            ...
        }

        return View(stats);   
    }

In my partial view.. (no refer jquery, jquery-ui script)

<script type="text/javascript">
$(function () {
    $('#txtStartDate').datepicker({
        dateFormat: 'yy-mm-dd',
        prevText: ..,
        nextText: ..,
        monthNames: ..,
        monthNamesShort: ..,
        dayNames: ...
        dayNamesShort: ...,
        dayNamesMin: ...,
        showMonthAfterYear: ..,
        yearSuffix: ..
    });
});

<input type="text" id="txtStartDate" value="@startDate" class="form-control" />

In that case, I can see hasDatePicker class in developer tool but calendar doesn't appear and It's nothing inside. Even more, I can't see any error message in my console.

In chrome developer tool ...

<div id="ui-datepicker-div" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>

My main page, I have exactly same datepicker but it works fine.

In chrome developer tool...

<input type="text" id="current_date1" name="current_date1" class="form-control date-picker hasDatepicker">

datepicker in main view

How can I solve the problem?

1 Answer 1

1

I had a similar situation to this and it only worked when I added the datepicker function after my partial view is rendered and not in the shared layout.

So in your case would be after opening the dialog

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.