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


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Still you would need a JavaScript event listener on the dropdown to observe when its value changes and enable the button.</p>
<p>The principle would be the same: observing when the input (a <code>&lt;select&gt;</code> tag in this case) changes, check if the value is blank, and toggle the “disabled” attribute of the button.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="133564" 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/how-do-i-disable-a-button-in-elixir/23402/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-133564" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="133564"
                     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="133579" data-post-id="133579">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Some example HTML/JS:</p>
<pre><code class="lang-plaintext">&lt;!DOCTYPE html&gt;
&lt;html lang="eng"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Enable/Disable Example - select&lt;/title&gt;
    &lt;style&gt;
     select {
       -webkit-appearance: none;
       -moz-appearance: none;
       appearance: none;
       box-sizing: border-box;
       padding: .2em 1.4em .2em .8em;
       border: 1px solid #aaa;
       border-radius: .5em;
       box-shadow: 0 1px 0 1px rgba(0,0,0,.04);
	     background-color: #fff;
	     /* note: bg image below uses 2 urls. The first is an svg data uri for the arrow icon, and the second is the gradient. 
		      for the icon, if you want to change the color, be sure to use `%23` instead of `#`, since it's a url.
          You can also swap in a different svg icon or an external image reference
	      */
	     background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'),
	     linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%);
	     background-repeat: no-repeat, repeat;
	     /* arrow icon position (1em from the right, 50% vertical) , then gradient position*/
	     background-position: right .7em top 50%, 0 0;
	     /* icon size, then gradient */
	     background-size: .65em auto, 100%;

     }
     select:required:invalid {
       color: gray;
     }
     option[value=""][disabled] {
       display: none;
     }
     option {
       color: black;
     }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="http://www.example.com/" method=""&gt;
      &lt;p&gt;
        Select:
        &lt;select id="select-field" size="1" required&gt;
          &lt;option value="" selected disabled&gt;Please choose...&lt;/option&gt;
          &lt;option&gt;one&lt;/option&gt;
          &lt;option&gt;two&lt;/option&gt;
          &lt;option&gt;three&lt;/option&gt;
        &lt;/select&gt;
      &lt;/p&gt;
      &lt;p&gt;
        &lt;input type="submit" value="Search" disabled&gt;
        &lt;input type="reset" value="Reset"&gt;
      &lt;/p&gt;
    &lt;/form&gt;

    &lt;script&gt;
     // IIFE
     (function () {

       function isInputEmpty(input) {
         return input.value.trim() === ""
       }

       function initialize(_event) {
         let form = document.querySelector('form')
         let submit = document.querySelector('input[type="submit"]')
         let selectField = document.getElementById('select-field')

         const syncSubmit = function (_event) {
           submit.disabled = isInputEmpty(selectField)
         }
         const resetListener = function(_event) {
           // run after reset event is complete
           setTimeout(syncSubmit, 0)
         }

         syncSubmit()
         selectField.addEventListener('change', syncSubmit)
         form.addEventListener('reset', resetListener)
       }

       if (document.readyState === 'loading') {
         // Loading hasn't finished yet - initialize when ready
         document.addEventListener('DOMContentLoaded', initialize, {once: true})

       } else {
         // 'DOMContentLoaded' has already fired
         initialize(null);
       }

     }())
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;

</code></pre>
<hr>
<p>Plain HTML may already do enough for you</p>
<pre><code class="lang-plaintext">&lt;!DOCTYPE html&gt;
&lt;html lang="eng"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Enable/Disable Example Plain-HTML&lt;/title&gt;
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="http://www.example.com/" method=""&gt;
      &lt;label for="text-field"&gt;Label:&lt;/label&gt;
      &lt;input type="text" name="sometext" id="text-field" required&gt;
      &lt;input type="submit" value="Search"&gt;
      &lt;input type="reset" value="Reset"&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>By marking the <code>input</code> as <code>required</code> a <code>Please fill out this field</code> tooltip will appear on the empty field when the submit button is clicked (and form submission is stopped).</p>
<p>With CSS you can <strong>fake</strong> disabling the submit button to some degree:</p>
<pre><code class="lang-plaintext">&lt;!DOCTYPE html&gt;
&lt;html lang="eng"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;title&gt;Enable/Disable Example CSS-based&lt;/title&gt;
    &lt;style&gt;
     input:required:invalid ~ input[type="submit"] {
       pointer-events: none;
       opacity: .5;
     }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;form action="http://www.example.com/" method=""&gt;
      &lt;label for="text-field"&gt;Label:&lt;/label&gt;
      &lt;input type="text" name="sometext" id="text-field" required&gt;
      &lt;input type="submit" value="Search"&gt;
      &lt;input type="reset" value="Reset"&gt;
    &lt;/form&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>… though the markup / styling can be a bit challenging and fragile.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="133579" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-do-i-disable-a-button-in-elixir/23402/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-133579" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="133579"
                     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="187867" data-post-id="187867">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Here is the simplest way to achieve it with AlpineJS and Surface, though you can use standard Phoenix eex.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule Components.MyButton do
  use Surface.Component

  property active, :boolean, default: true

  def render(assigns) do
    ~H"""
    &lt;span x-data="{ disable: {{not @active}} }"&gt;
    &lt;button
    x-bind:disabled="disable"
    phx-disable-with="Saving..."&gt;
    {{ @inner_content.([]) }}
    &lt;/button&gt;
    &lt;/span&gt;
    """
  end
</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="187867" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-do-i-disable-a-button-in-elixir/23402/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-187867" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="187867"
                     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 #13"></div>
  </section>
</div>
    <div class="postbit" id="210169" data-post-id="210169">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Tolteque" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Tolteque
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This may work</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">                    &lt;button type="button" class="inline-flex justify-center"
                      phx-click  = "open_delete_modal"
                      phx-value-provider_name = &lt;%= provider.name %&gt;
                      phx-value-provider_id   = &lt;%= provider.id %&gt;
                      &lt;%= if @user.provider.id == provider.id do %&gt;
                        disabled
                      &lt;% end %&gt;
                    &gt;
                      &lt;i class="fas fa-trash"&gt;&lt;/i&gt;Delete
                    &lt;/button&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="210169" 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/how-do-i-disable-a-button-in-elixir/23402/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-210169" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="210169"
                     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 #14"></div>
  </section>
</div>
    <div class="postbit" id="211554" data-post-id="211554">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You can do what you are requesting with Phoenix LiveView, as follows:</p>
<ul>
<li>As you type in the input, validate the input by handling a <code>phx-change</code> event.  In this example, the validation simply updates the current value of the input into the <code>socket.assigns</code></li>
<li>When the input is validated, the input becomes enabled by removing the <code>disabled</code> parameter from the HTML <code>input</code> element</li>
<li>You can either add some logic inside the <code>leex</code> file like the <code>disable until non-blank</code> example, to examine a <code>socket.assigns</code> parameter value or you can call a function that performs more complex input validation</li>
</ul>
<p>In your LiveView leex file, as an example, pushing the current value of the input into <code>socket.assigns.reply</code> allows for checking for a non-blank input</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">            &lt;form class="query__form" phx-submit="submit_reply" phx-change="validate_reply"&gt;
                &lt;div class="input-group"&gt;
                    &lt;label class="query__replylabel" for="reply"&gt;
                        Hey &lt;%= @handle %&gt;, post your reply!
                    &lt;/label&gt;
                &lt;/div&gt;

                &lt;div class="post_send"&gt;
                  &lt;input id="reply" class="reply_input" type="text" name="reply" maxlength="90" /&gt;
                  &lt;button class="post_send_button" type="submit" name="submit" &lt;%= if @reply == "" do %&gt;disabled="disabled"&lt;% end %&gt;&gt;Submit&lt;/button&gt;
                &lt;/div&gt;
            &lt;/form&gt;
</code></pre>
<p>To use a function to validate the input value, you can call the function like:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;button class="post_send_button" type = "submit" name = "submit" value = "this_submit" &lt;%= if me_disabled?(@socket_param1, @socket_param2) do %&gt;disabled="disabled"&lt;% end %&gt;&gt;Submit&lt;/button&gt;
</code></pre>
<p>Then, add the associated function in your supporting view module, to return a true/false value:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def me_disabled?(my_server, me) do
    client = MyServer.get_client_by_id(my_server, me)
    # IO.puts "MyServerView me_disabled? client: #{inspect client}"
    result =
    if client !== nil do
      if client.muted == true &amp;&amp; client.id == me do
        true
      else
        false
      end
    else
      false
    end
    result
  end
</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="211554" 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/how-do-i-disable-a-button-in-elixir/23402/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-211554" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="211554"
                     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 #15"></div>
  </section>
</div>
    <div class="postbit" id="225055" data-post-id="225055">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sajid" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sajid
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Yes, you can do this by simply putting disabled: true macro in the submit tag of the template.</p>
<p>&lt;%= submit “Send Promo”, disabled: <span class="mention">@disabled</span> %&gt;</p>
<p>In live views, follow these steps to achieve the results:</p>
<ol>
<li>Use schemaless changesets to check if inputs in the text fields are valid?</li>
<li>Assign initial state of button in a variable (lets call is disabled: true) in mount function</li>
<li>Use &lt;%= submit “Send Promo”, disabled: <span class="mention">@disabled</span> %&gt; while rending html code in your render function or in template</li>
<li>implement a handle_event function for phx_change: event, change the state of disabled: to false if changeset is valid.</li>
</ol>
<p>Consider example below:</p>
<p>Module:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule PentoWeb.PromoLive do
  use PentoWeb, :live_view
  alias Pento.Promo
  alias Pento.Promo.Recipient

  def mount(_params, _session, socket) do
    {:ok,
     socket
     |&gt; assign_recipient()
     |&gt; assign_changeset()
     |&gt; assign(disabled: true)}
  end

  def handle_event(
        "validate",
        %{"recipient" =&gt; recipient_params},
        %{assigns: %{recipient: recipient}} = socket
      ) do
    changeset =
      recipient
      |&gt; Promo.change_recipient(recipient_params)
      |&gt; Map.put(:action, :validate)

    {:noreply,
     socket
     |&gt; assign(:changeset, changeset)
     |&gt; assign(disabled: !changeset.valid?)}
  end

  def handle_event(
        "send",
        %{"recipient" =&gt; recipient_params},
        socket
      ) do
    # Call email service and email code
     case Promo.send_promo(recipient_params) do
      {:ok, _} -&gt;

    {:noreply,
     socket
     |&gt; put_flash(:info, "Promo sent successfully")
     |&gt; push_redirect(to: socket.assigns.return_to)}
     else
      {:noreply,
       socket
       |&gt; put_flash(:error, "Error sending promo")}
     end
  end

  def assign_recipient(socket) do
    socket
    |&gt; assign(:recipient, %Recipient{})
  end

  def assign_changeset(%{assigns: %{recipient: recipient}} = socket) do
    socket
    |&gt; assign(:changeset, Promo.change_recipient(recipient))
  end
end


</code></pre>
<p>and  template:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;%= f = form_for @changeset, "#",
id: "promo-form",
phx_change: "validate",
phx_submit: "send" %&gt;
&lt;%= label f, :first_name %&gt;
&lt;%= text_input f, :first_name %&gt;
&lt;%= error_tag f, :first_name %&gt;
&lt;%= label f, :email %&gt;
&lt;%= text_input f, :email%&gt;
&lt;%= error_tag f, :email %&gt;
&lt;%= submit "Send Promo", phx_disable_with: "Sending promo...", disabled: @disabled %&gt;
&lt;/form&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="225055" 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/how-do-i-disable-a-button-in-elixir/23402/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-225055" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="225055"
                     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 #16"></div>
  </section>
</div>
    <div class="postbit" id="243789" data-post-id="243789">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Stumbled upon this question via Google, sorry for bumping an old thread, but for disabling phx-click events, this actually works for <code>~L</code> templates:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">phx-click="&lt;%= if item.price &lt;= @user.money do %&gt;buy_item&lt;% end %&gt;"
</code></pre>
<p>Maybe not the prettiest, but simple and seems to work.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="243789" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-do-i-disable-a-button-in-elixir/23402/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-243789" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="243789"
                     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 #17"></div>
  </section>
</div>
    <div class="postbit" id="244893" data-post-id="244893">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>It seems that you can use directly assign the HTML.disabled tag and with a boolean coming from the assigns in a render(). The following worked without JS.</p>
<pre data-code-wrap="html"><code class="lang-html">&lt;button phx-click="stop" disabled={!@run}&gt;Stop&lt;/button&gt;
 &lt;button phx-click="start" disabled={@run}&gt;Start&lt;/button&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="244893" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-do-i-disable-a-button-in-elixir/23402/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-244893" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="244893"
                     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 #18"></div>
  </section>
</div>
    <div class="postbit" id="244895" data-post-id="244895">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In fact, with any boolean value, it does not need to be in the assigns, and could be a function <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="244895" data-batch-url="/posts/batch_likers">
                        2
                      </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/how-do-i-disable-a-button-in-elixir/23402/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-244895" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="244895"
                     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 #19"></div>
  </section>
</div>
    <div class="postbit" id="254596" data-post-id="254596">
  <section>
    <div class="post-wrap">


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

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi <a class="mention" href="/u/sajid" rel="nofollow">@sajid</a></p>
<p>I was reading your “send” event handler as I’m going through the Phoenix LiveView book too, and note it’s not the right way to use “case”:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir"> def handle_event(
        "save",
        %{"recipient" =&gt; recipient_params},
        socket
      ) do
    # Call email service and email code
    case Promo.send_promo(recipient_params, socket) do
      {:ok, _} -&gt;
        {:noreply,
         socket
         |&gt; put_flash(:info, "Promo code sent successfully!")
         |&gt; assign(:recipient, %Recipient{})}

      {_, _} -&gt;
        {:noreply,
         socket
         |&gt; put_flash(:error, "Error sending promo code!")}
    end
  end
</code></pre>
<p>This works, but I’m not sure how to wipe the input fields of the Promo Sending code form (first_name and email)</p>
<p>Thanks,<br>
Gavin.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="254596" 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/how-do-i-disable-a-button-in-elixir/23402/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-254596" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="254596"
                     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 #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/23402/load_more?page=3">Load more posts (1 remaining)</a>
</div></template></turbo-stream>