How to prevent client dateSelected from being fired?

3 posts, 1 answers
  1. Ron Cirka
    Ron Cirka avatar
    19 posts
    Member since:
    Jul 2009

    Posted 05 Aug 2009 Link to this post

    I am trying to update the time in timepicker when the time is selected. However, when i try to update the time, the OnDateSelected handler is called, causing an infinite loop. How can I disable the event handler temporarily so I can update the time?


    <telerik:RadTimePicker ID="uxStartTime" runat="server" Skin="Default" TimeView-RenderDirection="Horizontal" 
                                                            Width="85px" ClientEvents-OnDateSelected="dateSelected" TimeView-Interval="0:30" 
                                                            TimeView-Columns="4" EnableTyping="false" /> 

    function dateSelected(sender, eventArgs) 
            { 
                var endTime = sender.get_selectedDate(); 
                endTime.setMinutes(endTime.getMinutes() + 10); 
                sender.set_selectedDate(endTime); 
            } 

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2009 Link to this post

    Hello Ron,

    Try the following approach and see whether it is working as you expected.

    ASPX:
     
    <telerik:RadTimePicker ID="uxStartTime" runat="server" Skin="Default" TimeView-RenderDirection="Horizontal" 
        Width="85px" ClientEvents-OnPopupOpening="OnPopupOpening" ClientEvents-OnDateSelected="dateSelected" 
        TimeView-Interval="0:30" TimeView-Columns="4" EnableTyping="false"
    </telerik:RadTimePicker> 

    JavaScript:
     
    <script type="text/javascript"
    var t = 0; 
    function OnPopupOpening(sender, eventArgs)  
        t=0; 
    function dateSelected(sender, eventArgs)  
    {  
        if(t==0) 
        { 
            t=1; 
            var endTime = sender.get_selectedDate();  
            endTime.setMinutes(endTime.getMinutes() + 10);  
            sender.set_selectedDate(endTime);         
        } 
    </script> 

    -Shinu.
  3. Ron Cirka
    Ron Cirka avatar
    19 posts
    Member since:
    Jul 2009

    Posted 06 Aug 2009 Link to this post

    Thanks Shinu, that workaround should work for me.

    Ron 
Back to Top