|
| 1 | +--- |
| 2 | +title: Events |
| 3 | +page_title: RadFloatingActionButton Client-side Events |
| 4 | +description: Check our Web Forms article about the API of RadFloatingActionButton object. |
| 5 | +slug: floatingactionbutton/client-side-programming/events |
| 6 | +tags: overview |
| 7 | +published: True |
| 8 | +position: 1 |
| 9 | +--- |
| 10 | + |
| 11 | +# Events |
| 12 | + |
| 13 | +This article lists the client-side events of the **RadFloatingActionButton** and how to use them. |
| 14 | + |
| 15 | +All events follow the MS AJAX client events convention and receive two arguments: |
| 16 | + |
| 17 | +1. `sender` - the [RadFloatingActionButton]({%slug floatingactionbutton/client-side-programming/overview%}) instance that raised the event. |
| 18 | +1. `event arguments` - event-specific data provided to the developer. |
| 19 | + |
| 20 | +RadFloatingActionButton is a wrapper over the Kendo UI FloatingActionButton widget and so it exposes the [client events](https://docs.telerik.com/kendo-ui/api/javascript/ui/floatingactionbutton#events) and data it does. You can find a list below. |
| 21 | + |
| 22 | +>note The event data is wrapped according to the MS AJAX conventions and the fields you can see in the underlying Kendo Widget are available through a method like `get_<fieldName>()` in the `event arguments` argument of the handler (that is, the second argument the event handler receives). To cancel a cancelable event, you must call its `args.set_cancel(true);` method. |
| 23 | +
|
| 24 | +The exceptions are the OnInitialize and OnLoad events that are specific to the MS AJAX framework. |
| 25 | + |
| 26 | +>caption Listing 1: The client-side events exposed by RadFloatingActionButton |
| 27 | +
|
| 28 | +* **OnInitialize** — Fired just before the RadFloatingActionButton client-side object is initialized. |
| 29 | + |
| 30 | +* **OnLoad** — Fired when RadFloatingActionButton is initialized. |
| 31 | + |
| 32 | +* [OnClick](https://docs.telerik.com/kendo-ui/api/javascript/ui/floatingactionbutton/events/click) — Fires when the user clicks on a the FloatingActionButton. (Cancelable event) |
| 33 | + |
| 34 | +* [OnExpand](https://docs.telerik.com/kendo-ui/api/javascript/ui/floatingactionbutton/events/collapse) — Fires when the speed-dial popup is opened and its animation is finished.. Available only when Items are defined. |
| 35 | + |
| 36 | +* [OnCollapse](https://docs.telerik.com/kendo-ui/api/javascript/ui/floatingactionbutton/events/collapse) — Fires when the speed-dial popup is closed and its animation is finished. Available only when Items are defined. |
| 37 | + |
| 38 | +* Item's Click event - each Item defined in the RadFloatingActionButton exposes its own Click event that fires when the item itself is being clicked. |
| 39 | + |
| 40 | +## Examples |
| 41 | + |
| 42 | +>caption Example 1: Store a reference to the client-side object through the OnLoad event |
| 43 | +
|
| 44 | +````ASP.NET |
| 45 | +<script> |
| 46 | + var floatingButton, kendoFloatingActionButton; |
| 47 | + function OnLoad(sender, args) { |
| 48 | + floatingButton = sender; //the RadFloatingActionButton |
| 49 | + kendoFloatingActionButton = sender.get_kendoWidget(); //the underlying Kendo FloatingActionButton |
| 50 | + } |
| 51 | +</script> |
| 52 | +<telerik:RadFloatingActionButton runat="server" ID="RadFloatingActionButton"> |
| 53 | + <ClientEvents OnLoad="OnLoad" /> |
| 54 | +</telerik:RadFloatingActionButton> |
| 55 | +```` |
| 56 | + |
| 57 | +>caption Example 2: Get the data associated with the clicked item |
| 58 | +
|
| 59 | +````ASPX |
| 60 | +<script> |
| 61 | + function floatingButtonExpanded(sender, args) { |
| 62 | + alert("Floating button Expanded!") |
| 63 | + } |
| 64 | + function floatingButtonCollapsed(sender, args) { |
| 65 | + alert("Floating button Collapsed!") |
| 66 | + } |
| 67 | +</script> |
| 68 | +<telerik:RadFloatingActionButton runat="server" Size="Large" ID="RadFloatingActionButton1" Icon="share" PositionMode="Absolute" Align="BottomCenter"> |
| 69 | + <ClientEvents OnExpand="floatingButtonExpanded" OnCollapse="floatingButtonCollapsed" /> |
| 70 | + <AlignOffsetSettings X="0" Y="100" /> |
| 71 | + <Items> |
| 72 | + <telerik:FloatingActionButtonItem Label="Download" Icon="download"></telerik:FloatingActionButtonItem> |
| 73 | + <telerik:FloatingActionButtonItem Label="Print" Icon="print"></telerik:FloatingActionButtonItem> |
| 74 | + <telerik:FloatingActionButtonItem Label="Email" Icon="email"></telerik:FloatingActionButtonItem> |
| 75 | + </Items> |
| 76 | +</telerik:RadFloatingActionButton> |
| 77 | +```` |
| 78 | + |
| 79 | +>caption Example 3: Get the data associated with the clicked item |
| 80 | +
|
| 81 | +````ASPX |
| 82 | +<script> |
| 83 | + function dialItemClicked(eventArguments) { |
| 84 | + alert('"' + eventArguments.item.label +'" item Clicked.'); |
| 85 | + } |
| 86 | +</script> |
| 87 | +<telerik:RadFloatingActionButton runat="server" Size="Large" ID="RadFloatingActionButton1" Icon="share" PositionMode="Absolute" Align="BottomCenter"> |
| 88 | + <AlignOffsetSettings X="0" Y="100" /> |
| 89 | + <Items> |
| 90 | + <telerik:FloatingActionButtonItem Label="Download" Icon="download" OnClientClicked="dialItemClicked"></telerik:FloatingActionButtonItem> |
| 91 | + <telerik:FloatingActionButtonItem Label="Print" Icon="print" OnClientClicked="dialItemClicked"></telerik:FloatingActionButtonItem> |
| 92 | + <telerik:FloatingActionButtonItem Label="Email" Icon="email" OnClientClicked="dialItemClicked"></telerik:FloatingActionButtonItem> |
| 93 | + </Items> |
| 94 | +</telerik:RadFloatingActionButton> |
| 95 | +```` |
| 96 | + |
| 97 | +See live sample of handling the client events in our [Client-side events demo](https://demos.telerik.com/aspnet-ajax/floatingactionbutton/events/defaultcs.aspx) |
| 98 | + |
| 99 | + |
| 100 | +# See Also |
| 101 | + |
| 102 | + * [RadFloatingActionButton Client-side Object]({%slug floatingactionbutton/client-side-programming/overview%}) |
| 103 | + * [Client-side events demo](https://demos.telerik.com/aspnet-ajax/floatingactionbutton/events/defaultcs.aspx) |
| 104 | + |
| 105 | + |
0 commit comments