Last active
March 31, 2022 10:45
-
-
Save pama/10ff1e508994e81ea13472017ffc8615 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= turbo_stream.update "panel" do %> | |
<% if params[:position].to_i <= 5 %> | |
<p>Less or equal to 5</p> | |
<% else %> | |
<p>more than 5</p> | |
<% end %> | |
<% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "@hotwired/stimulus" | |
import { get } from "@rails/request.js" | |
export default class extends Controller { | |
greet(event) { | |
let value = event.currentTarget.value | |
get(`/home/greet?position=${value}`, { | |
responseKind: "turbo-stream" | |
}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def index | |
end | |
def greet | |
respond_to do |format| | |
format.turbo_stream | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div data-controller="hello"> | |
<input type="range" | |
name="custom_range" | |
id="custom_range" | |
value="6" | |
min="0" | |
max="10" | |
step="0.5" data-action="change->hello#greet"> | |
<div id="panel"></div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
get 'home/index' | |
get 'home/greet' | |
root "home#index" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment