[JAVA] How to get boolean value with jQuery in rails simple form

I was worried about how to implement what was checked by jquery, but I did not have much information and tried to implement it myself

# rails form,id is"testBool"will do
= f.input :test_bool, as: :boolean
 
// jquery
$('#testBool').on('click', function() {
  console.log($(this)[0]['checked'])
})
 
-> 
false
true
 

If you go with this implementation method, you can get true and false dynamically, so control on the js side will be much easier.

Reference article

None

Recommended Posts

How to get boolean value with jQuery in rails simple form
How to introduce jQuery in Rails 6
How to get along with Rails
How to use JQuery in js.erb of Rails6
[Rails] How to get the user information currently logged in with devise
[How to insert a video in haml with Rails]
How to store data simultaneously in a model associated with a nested form (Rails 6.0.0)
How to query Array in jsonb with Rails + postgres
How to get started with creating a Rails app
How to deploy jQuery in your Rails app using Webpacker
Mapping to a class with a value object in How to MyBatis
How to deploy jQuery on Rails
How to get started with slim
[Rails] How to write in Japanese
How to get parameters in Spark
How to install Swiper in Rails
How to solve the problem when the value is not sent when the form is disabled in rails and sent
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
How to rename a model with foreign key constraints in Rails
How to implement search functionality in Rails
How to get date data in Ruby
How to use custom helpers in rails
[Rails] How to use rails console with docker
How to insert a video in Rails
[Note] How to get started with Rspec
How to use MySQL in Rails tutorial
[rails] How to configure routing in resources
How to get the date in java
How to implement ranking functionality in Rails
How to use credentials.yml.enc introduced in Rails 5.2
How to build Rails 6 environment with Docker
[Rails] How to log in with a name by adding a devise name column
How to get the value after "_" in Windows batch like Java -version
How to get the setting value (property value) from the database in Spring Framework
How to display the text entered in text_area in Rails with line breaks
[Rails] How to apply the CSS used in the main app with Administrate
Get the value of enum saved in DB by Rails with attribute_before_type_cast
How to create your own annotation in Java and get the value
How to get keycloak credentials in interceptor class
[Rails] How to use select boxes in Ransack
How to translate Rails into Japanese in general
How to prevent direct URL typing in Rails
How to get started with Eclipse Micro Profile
How to separate .scss by controller in Rails
How to conditionally add html.erb class in Rails
One way to redirect_to with parameters in rails
How to implement a like feature in Rails
How to easily create a pull-down in Rails
[Rails] How to easily implement numbers with pull-down
How to build API with GraphQL and Rails
Rails beginners tried to get started with RSpec
How to get resource files out with spring-boot
[Ruby on Rails] How to install Bootstrap in Rails
[Rails] How to build an environment with Docker
[Rails] How to get success and error messages
How to make a follow function in Rails
[Rails] How to use PostgreSQL in Vagrant environment
How to check Rails commands in the terminal
I want to get the value in Ruby
How to get the ID of a user authenticated with Firebase in Swift
[Rails] How to register multiple records in the intermediate table with many-to-many association