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

The script in RadCodeBlock vs $(document).ready

0 Answers 121 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
liu
Top achievements
Rank 1
liu asked on 09 Feb 2018, 07:56 PM

I got a question about the execution sequence/order between the script in RadCodeBlock and $(document).ready in JQuery.

I defined <telerik:RadDateTimePicker ID="RadDateTimePickerCalendarStart" runat="server"/><ClientEvents OnDateSelected="CalendarStartSelected" /> </telerik:RadDateTimePicker> and <asp:HiddenField ID="CalendarStartHidden" runat="server" Value="" />.

Added the following script to assign/store the selected date value into CalendarStartHidden hidden input.

<telerik:RadCodeBlock runat="server">
         <script type="text/javascript">
             function CalendarStartSelected(sender, eventArgs) {
                 var selectedDate = sender.get_selectedDate();
                 $("#<%=CalendarStartHidden.ClientID%>").val(selectedDate == null ? '' : selectedDate.format("MM/dd/yyyy"));
             }

       </script>
</telerik:RadCodeBlock>

 

I also want to do some extra work when date time is changed, and defined the following script in $(document).ready with JQuery:

            $('#<%=RadDateTimePickerCalendarStart.ClientID%>).on("change", function (event) {

               UseChangedDateTimeValueToCalculateData();

            });

 

However, UseChangedDateTimeValueToCalculateData is executed earlier than CalendarStartSelected when the date time is changing/changed.

Is there any way I can make UseChangedDateTimeValueToCalculateData is executed later than CalendarStartSelected?

My goal here, is to use the correct changed date time value, to calculate the final statistics number.

Thank you.

 

No answers yet. Maybe you can help?

Tags
Calendar
Asked by
liu
Top achievements
Rank 1
Share this question
or