jQuery datepicker as parent of AjaxRadioList

Sep 20, 2011 at 4:01 AM

I have an odd behavior here. I am implementing a jquery datepicker for a datefield that acts as a parent to an AjaxRadioList field. If I implement a popup date it works but NOT for an inline date.

So the following code works, wherein each time a day is selected on the calendar the calendar action (in AvailableTimesAjaxRadioListController) is being called.

 

 
<div id="dtX">
            @Html.TextBoxFor(m => m.ScheduledDate)
        </div>

<div >
            @Html.AjaxRadioList("ScheduledTime", controller: "AvailableTimesAjaxRadioList", parentId: "ScheduledDate")            
        </div>


/* jquery code */
  $(document).ready(function () {
        $(function () {
            $("#ScheduledDate").datepicker({
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true
            });
        });

But not this:

 

<div id="dtX">
            @Html.HiddenFor(m => m.ScheduledDate)
        </div>

<div >
            @Html.AjaxRadioList("ScheduledTime", controller: "AvailableTimesAjaxRadioList", parentId: "ScheduledDate")            
        </div>


/* jquery code */
  $(document).ready(function () {
        $(function () {
            $("#dtX").datepicker({
                altField: "#ScheduledDate", 
                changeMonth: true,
                changeYear: true,
                showButtonPanel: true
            });
        });

 

 

The only time the controller action is called is on page load. Each time a day is selected on the calendar, the controller action is no longer invoked.

Coordinator
Sep 20, 2011 at 9:49 AM

it will get called when the parenId will trigger a change event, try setting dtX as parentId

Sep 20, 2011 at 12:36 PM
o wrote:

...the parenId will trigger a change event

That make sense.

It worked, thanks!