Remove all clicked event handler

5 posts, 0 answers
  1. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 04 Feb 2013 Link to this post


    I just wanted to know how I can remove all OnClientClicked event handler in javacsript client side.

    I know there is a "remove_clicked()" but I must pass the function's name, but I don't know the name, so I want to remove all handler on the Clicked event. Is that possible?

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Feb 2013 Link to this post

    Hi Jocelyn

    I am not quite sure about your scenario.Whats the use of a RadButton enabled and having its event OnClientClicked not to fire.
    Better try disabling the RadButton
    <telerik:RadButton ID="RadButton1" runat="server" Text="Rbutton" OnClientLoad="OnClientLoad">
    <script type="text/javascript">
    function OnClientLoad(sender, args)

  3. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 06 Feb 2013 Link to this post


    this is because I want to set the event client side using "add_clicked()" function. But I want to remove all other handler already set for this event on my button.


    Button1 call function1 and function2 OnClientClicked.

    I want to set Button1 OnClientClicked to function3, but I don't want function1 and function2 to be called, so I must remove them.

    When I use "add_clicked(function3)" it will call function1, function2 and function3 when I click on the button. That's why I am asking how I can remove all Handlers on this event (Client side) before doing "add_clicked(function3)".

  4. Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 07 Feb 2013 Link to this post

    Hello Jocelyn,

    You can store the names of the dynamically added JavaScript functions (which are to be executed, when OnClientClicked event is triggered) in a custom child object (located in the parent client-side object of the RadButton). Therefore before adding new function to the OnClientClicked event handler, you can remove the previous functions from the stack (you have already stored their names so you can call remove_clicked() method for example). I have created an example and attached it in the archive. You can also watch a short video with the example here.

    Danail Vasilev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 13 Feb 2013 Link to this post

    Hi Danail,

    this is a good solution, but only if I add my handler on client side. In my case, I can set the OnClientClicked server side.

    I found another solution which works for me:

    myButton.get_events()._list.clicked = null;

    Thanks for your help!
Back to Top