# Calling a method on load

**URL:** <https://forums.fusetools.com/t/calling-a-method-on-load/5816>\
**Category:** How-to Discussions\
**Created:** [July 3, 2015, 10:25am UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816 "2015-07-03T10:25:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anders\_Jakob\_Sivesin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_jakob_sivesin/32/548_2.png) [@Anders\_Jakob\_Sivesin](https://forums.fusetools.com/u/Anders_Jakob_Sivesin)\
**Post date:** [July 3, 2015, 10:25am UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/1 "2015-07-03T10:25:30Z")

</div>

How would I go about to call a method as soon as the app loads (without user interaction) or alternatively as soon as a specific page has loaded?

I want to automatically load settings and update some details in the UI without having the user clicking a button.

---

<div class="post-metadata">

**Author:** ![Anders\_Jakob\_Sivesin](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_jakob_sivesin/32/548_2.png) [@Anders\_Jakob\_Sivesin](https://forums.fusetools.com/u/Anders_Jakob_Sivesin)\
**Post date:** [July 3, 2015, 10:53am UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/2 "2015-07-03T10:53:31Z")

</div>

SOLVED: Stumbled upon the solution: [https://www.fusetools.com/developers/guides/topics/appclass](https://www.fusetools.com/developers/guides/topics/appclass)

---

<div class="post-metadata">

**Author:** ![Jalakoo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jalakoo/32/468_2.png) [@Jalakoo](https://forums.fusetools.com/u/Jalakoo)\
**Post date:** [April 14, 2018, 3:20pm UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/3 "2018-04-14T15:20:51Z")

</div>

Linked page no longer exists.

---

<div class="post-metadata">

**Author:** ![jesusmartinoza](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jesusmartinoza/32/659_2.png) [@jesusmartinoza](https://forums.fusetools.com/u/jesusmartinoza)\
**Post date:** [April 14, 2018, 4:27pm UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/4 "2018-04-14T16:27:46Z")

</div>

This is the new link of App Class  
[https://docs.fusetools.com/fuse/app.html](https://docs.fusetools.com/fuse/app.html)

---

<div class="post-metadata">

**Author:** ![Jalakoo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jalakoo/32/468_2.png) [@Jalakoo](https://forums.fusetools.com/u/Jalakoo)\
**Post date:** [April 15, 2018, 3:44pm UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/5 "2018-04-15T15:44:27Z")

</div>

Thanks jesusmartinoza. Not sure if you or anyone else knows, but whatever Anders Sivesind saw in the older documentation was not apparent to me in the new documentation.

At first I though an `<OnUpdate/>` tag could be used to trigger loading js code, but no such function name actually exists.

Then I tried adding:

```auto
// {config} coming from a .js file loaded earlier
<OnUserEvent Name="finished" Handler="{config}"/>
<PageLoaded>
    <RaiseUserEvent EventName="finished"/>
</PageLoaded>

```

But this also did not work. Is there not something equivalent to:

```auto
// jquery
$(document).ready(function() {
    console.log("Ready!");
});

```

---

<div class="post-metadata">

**Author:** ![jesusmartinoza](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jesusmartinoza/32/659_2.png) [@jesusmartinoza](https://forums.fusetools.com/u/jesusmartinoza)\
**Post date:** [April 16, 2018, 12:12am UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/6 "2018-04-16T00:12:24Z")

</div>

To execute JS code to configure user stuff you can use it like this:

```auto
<App>
  <JavaScript>
    // JavaScript executed on app startup
  </JavaScript>

  <!--- You regular app UI -->
</App>

```

Or if you want more control over the app, [Life Cycle](https://docs.fusetools.com/fusejs/lifecycle.html#example) module is for you 🙂

---

<div class="post-metadata">

**Author:** ![Jalakoo](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jalakoo/32/468_2.png) [@Jalakoo](https://forums.fusetools.com/u/Jalakoo)\
**Post date:** [April 17, 2018, 2:22pm UTC](https://forums.fusetools.com/t/calling-a-method-on-load/5816/7 "2018-04-17T14:22:55Z")

</div>

Thanks! Using the `<JavaScript>` tag is working best for me. I haven’t had any luck with the Lifecycle module when using Fuse Studio / viewport. Works fine on a device, but I didn’t want to have to build out all the time.
