# activate animation for a moment with javascript

**URL:** <https://forums.fusetools.com/t/activate-animation-for-a-moment-with-javascript/831>\
**Category:** How-to Discussions\
**Created:** [June 3, 2016, 9:08am UTC](https://forums.fusetools.com/t/activate-animation-for-a-moment-with-javascript/831 "2016-06-03T09:08:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Kobo](https://avatars.discourse-cdn.com/v4/letter/_/f05b48/32.png) [@\_Kobo](https://forums.fusetools.com/u/_Kobo)\
**Post date:** [June 3, 2016, 9:08am UTC](https://forums.fusetools.com/t/activate-animation-for-a-moment-with-javascript/831/1 "2016-06-03T09:08:30Z")

</div>

hi guys, i’m building a little app and i need to handle javascript error or success and showing them in the ui for a time like 2s

```auto
function sendMessage(){
        messages.save({
            message: "joyeux anniversai",
            senderid: "houhou",
            receiverid: "haha",
            rooms: chatRooms

        }, {
            success: function(messages) {
                console.log('messages sended')
                // Do something and show file as been saved
            },
            error: function(messages, error) {
                console.log('error sending the message')
                // The save failed.
                // Do something and show that it failed to save the file
            }
        })
        }

```

i have a WhileTrue condition that i need to activate when something is saved or not

```auto
<WhileTrue ux:Name="lou">
    <Change loudou.Opacity="1"/>
</WhileTrue>

```

so i need to activate this condition for 2 secondes , how can i do this.

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [June 3, 2016, 9:35am UTC](https://forums.fusetools.com/t/activate-animation-for-a-moment-with-javascript/831/2 "2016-06-03T09:35:30Z")

</div>

You can use the [timer API](https://www.fusetools.com/learn/fusejs#timer) for this. (Currently missing from the new docs so the link is for the old one. We’ll get that fixed as well).

Basically, the function that enables/shows the message can then also set up a timer to remove it again after 2 seconds.

---

<div class="post-metadata">

**Author:** ![\_Kobo](https://avatars.discourse-cdn.com/v4/letter/_/f05b48/32.png) [@\_Kobo](https://forums.fusetools.com/u/_Kobo)\
**Post date:** [June 3, 2016, 10:24am UTC](https://forums.fusetools.com/t/activate-animation-for-a-moment-with-javascript/831/3 "2016-06-03T10:24:33Z")

</div>

its working perfectly , thank you
