Skip to content

Instantly share code, notes, and snippets.

@kmelkon
Created August 25, 2013 10:38
Show Gist options
  • Save kmelkon/6333185 to your computer and use it in GitHub Desktop.
Save kmelkon/6333185 to your computer and use it in GitHub Desktop.
radio with bootstrap tabs issue
def deal_status
deal_id = params[:deal_id]
d = Deal.find_by_id(deal_id)
d.state = params[:state]
d.save
@deal_id = deal_id
@deal = d
respond_to do |format|
format.js
end
end
$("body").on("change", "form :radio", function(){
$(this).closest("form").submit();
});
class Deal < ActiveRecord::Base
attr_accessible :background, :company_id, :currency, :deal_category_id, :deal_status_id, :name, :offer, :user_id, :value, :status, :state
belongs_to :company
belongs_to :deal_catergory
belongs_to :deal_status
belongs_to :user
end
<div class="tab-pane" id="go-to-deals">
<% @deals.each do |d| %>
<address>
<%= d.value %><br>
<%= d.background %><br>
</address>
<div class="no-radio">
<div class="btn-group" data-toggle="buttons-radio">
<%= form_tag ("deal_status"), :remote => true, :class => "deals_status" do %>
<%= hidden_field_tag 'deal_id', d.id.to_s %>
<%= radio_button_tag( :state, "won"+d.id.to_s, d.state == "won", :class => "toggle-btn-left toggle-btn", :value =>"won") %>
<%= label_tag 'state_won'+d.id.to_s, "won", :class=>"btn" %>
<%= radio_button_tag :state, "lost"+d.id.to_s, d.state == 'lost', :class => "toggle-btn-center toggle-btn",:value => "lost" %>
<%= label_tag 'state_lost'+d.id.to_s, "lost",:class=>"btn" %>
<%= radio_button_tag :state, "pending"+d.id.to_s, d.state == 'pending',:class => "toggle-btn-right toggle-btn", :value => "pending" %>
<%= label_tag 'state_pending'+d.id.to_s, "pending",:class=>"btn" %>
<% end %>
</div>
</div>
<% end %>
<div>
<%= link_to "Add a deal", href="#new-deal-form", class: "pull-right inline" %>
</div>
<div class="hide">
<div id="new-deal-form" >
<%= render 'deals/new_deal' %>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment