This is a migrated thread and some comments may be shown as answers.

How to call date picker event in jQuery block?

1 Answer 202 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
khaled jendi
Top achievements
Rank 1
khaled jendi asked on 07 Jan 2015, 08:00 PM
Hi, I have this raddatepicker: 

                                                                                       <telerik:RadDatePicker ID="datePicker" runat="server" MinDate="1900-01-01" 
                                                                                            DateInput-Width="217px" Culture="en-GB" 
                                                                                            DateInput-Enabled="false"  Skin="Sunset" Width="247px"  >
                                                                                           <ClientEvents OnDateSelected="getTripsAndHistory" />
                                                                                            <Calendar ID="Calendar3" RangeMinDate="1900-01-01" runat="server" >
                                                                                            </Calendar>
                                                                                                <DateInput Enabled="False" DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"></DateInput>
                                                                                                <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                                                                        </telerik:RadDatePicker>

which has <ClientEvents OnDateSelected="getTripsAndHistory" />

The problem, I need to write the event in jQuery Ready block:

         (function ($) {
             $(document).ready(function () {

                 function getTripsAndHistory(sender, eventArgs) {
                     var date = eventArgs.get_renderDay().get_date();
                     var dfi = sender.DateTimeFormatInfo;
                     var formattedDate = dfi.FormatDate(date, dfi.ShortDatePattern);
                     alert(formattedDate + " was just " +
                     (eventArgs.get_renderDay().get_isSelected() ? "selected. " : "unselected. "));
                 }

             });
         })(jQuery);

I am getting an error in firebug --> ReferenceError: getTripsAndHistory is not defined
How can I solve it without removing the event function from jquery ready block?

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 12 Jan 2015, 09:40 AM
Hi Khaled,

I am afraid that this is not a supported scenario and you need to remove the function which you have assign to DateSelected client even from the document.ready. Generally this function will be executed when a date is selected and if you need to fire it when the control is loaded you can use the OnLoad event. Please check out the following code snippet.
<telerik:RadDatePicker ID="datePicker" runat="server" MinDate="1900-01-01"
    DateInput-Width="217px" Culture="en-GB" Calendar-ClientEvents-OnLoad="OnLoad"


Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar
Asked by
khaled jendi
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or