title: scroll to top of page - livewire component - alpine js
body: <p>I have an app created with laravel livewire where I'm loading a livewire component with multiple nested components that display one at a time depending upon a status variable. When each nested component is displayed the page is scrolled to the bottom. I'd like the default scroll be to the top. At the top of a nested component I've tried:</p>
  <pre><code>x-data x-init=&quot;window.scrollTo(0, 0)&quot;
  </code></pre>
  <p>I've also tried scrolling the page to the top using a click event prior to hiding component 1 and displaying component 2. This would be to ensure the page is scrolled to the top prior to displaying component 2.</p>
  <pre><code>x-data x-on:click.document=&quot;window.scrollTo(0, 0)&quot;
  </code></pre>
  <p>Neither approach is working. Thanks in advance.</p>