<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="283512" data-post-id="283512">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nathanalderson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nathanalderson/120/26820_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nathanalderson
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In case it helps anyone else, I was having the same types of errors (<code>Uncaught (in promise) TypeError: i is not a function</code>) and finally resolved them by wrapping a data update from within a <code>$watch</code> in <code>$nextTick</code>.</p>
<p>Simplified example:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;div
  x-data="{open: false, filter: 'all'}"
  x-init="$watch('filter', val =&gt; {
    $nextTick(() =&gt; open = false) // &lt;-- $nextTick wrapper added
  })"
&gt;
</code></pre> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="283512" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-blowing-up-alpine-state/42543/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-283512" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="283512"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="315466" data-post-id="315466">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kuroda" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kuroda/120/3776_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kuroda
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I ran into a similar problem; adding an <code>id</code> attribute to an element with the <code>x-data</code> attribute did not solve my problem.</p>
<p>After some trial and error, I found the following workaround:</p>
<p>First, remove <code>window.Alpine.initTree(to)</code> from <code>onBeforeElUpdated</code>.</p>
<p>Then, add the <code>phx-hook="AlpineRoot"</code> attribute to the element with the <code>x-data</code> attribute or one of its ancestor elements.</p>
<p>Finally, define the following hook in your <code>app.js</code>:</p>
<pre data-code-wrap="javascript"><code class="lang-javascript">Hooks.AlpineRoot = {
  update() {
    window.Alpine.initTree(this.el)
  }
}
</code></pre>
<p>I hope my experience will be useful to someone.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="315466" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-blowing-up-alpine-state/42543/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-315466" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="315466"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="315473" data-post-id="315473">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="arcanemachine" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arcanemachine/120/29109_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  arcanemachine
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I’m a big fan of Alpine.js and it’s good to see others getting it to work with LV.</p>
<p>Have you seen this other thread on the topic? There’s some snippets in there that are also useful on working around some of the issues with Alpine:</p>
<aside class="quote quote-modified" data-post="8" data-topic="53409">
  <div class="title">
    <div class="quote-controls"></div>
    <img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/krishandley/48/27199_2.png" class="avatar">
    <div class="quote-title__text-content">
      <a href="https://forum.elixirforum.com/t/proper-alpinejs-integration-with-liveview/53409/8" rel="nofollow">Proper AlpineJS Integration with Liveview</a> <a class="badge-category__wrapper " href="/c/questions-help/questions/53" rel="nofollow"><span data-category-id="53" style="--category-badge-color: #C14BFB; --category-badge-text-color: #000000; --parent-category-badge-color: #C14BFB;" data-parent-category-id="171" data-drop-close="true" class="badge-category --style-square --has-parent" title="Elixir Questions / Help"><span class="badge-category__name">Questions</span></span></a>
    </div>
  </div>
  <blockquote>
    Just in case this helps… I was playing with Alpine again and found a way around a few issues I had previously had with something similar. 
Instead of having variables inside x-data, use an attribute and a mutation observer. 
&lt;div x-data="{foo: null}" foo={@foo} /&gt;

init() {
  this.foo = this.$el.getAttribute("foo");

  this.observer = new MutationObserver((mutations) =&gt; {
    mutations.forEach((m) =&gt; {
      if (m.attributeName == "foo") {
        this.foo = this.$el.getAttribute("foo");
      }…
  </blockquote>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="315473" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/liveview-blowing-up-alpine-state/42543/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-315473" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="315473"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>