How do I switch/toggle names between two or more names on single button?
For one condition I want the name to be as “Add”, and for the other condition I want the name changed to “Remove”. and switch between them based on status at the back end.
<%= button_tag "Add" , :id => "add_or_remove_button", :onclick => "javascript:add_or_remove_button()"%>
I can do “Add/Remove”, and clicking on the same button will still do the job. But I want it specific.
Since you didn’t say where the condition comes from, I will assume it is in an instance variable called
@button_conditionYou can do this (I haven’t tested it)
Take a look at: Button tag documentation