Created
March 23, 2015 20:56
-
-
Save irishsox5/4c06f1cc44afc4f33718 to your computer and use it in GitHub Desktop.
For Marcus's Help
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
<%= form_for(@stake) do |f| %> | |
<% if @stake.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@stake.errors.count, "error") %> prohibited this stake from being saved:</h2> | |
<ul> | |
<% @stake.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</div> | |
<% end %> | |
<%= f.hidden_field :user_id, :value => current_user.id %> | |
<div class="field"> | |
<%= f.label :tour_id %><br> | |
<%= f.collection_select :tour_id, Tour.all, :id, :name, include_blank: true %> | |
</div> | |
<div class="field"> | |
<%= f.label :tournament %><br> | |
<%= f.grouped_collection_select :tournament_id, @tours, :tournaments, :name, :id, :event, include_blank: true%> | |
<div class="input_fields_wrap"> | |
<button class="add_field_button">Add More Tournaments</button> | |
</div> | |
</div> | |
<div class="field"> | |
<%= f.label :total_amount_of_shares %><br> | |
<%= f.number_field :amount_of_shares, min:0 %> | |
</div> | |
<div class="field"> | |
<%= f.label :mark_up %><br> | |
<%= f.select :mark_up, options_for_select([["1.00","1.00"],["1.10", "1.10"],["1.15", "1.15"], ["1.20", "1.20"],["1.25","1.25"],["1.30", "1.30"], ["1.35","1.35"], ["1.40","1.40"],["1.45","1.45"],["1.50","1.50"]], f.object.mark_up)%> | |
</div> | |
<div class="field"> | |
<%= f.label :description %><br> | |
<%= f.text_area :description,:cols => 50, :rows => 8, placeholder: " ex: Minimium Shares, Tax Handling, etc"%> | |
</div> | |
<div class="actions"> | |
<%= f.submit %> | |
<button><%= link_to 'Back', stakes_path %></button> | |
</div> | |
<% end %> | |
<script> | |
$(document).ready(function() { | |
var max_fields = 10; //maximum input boxes allowed | |
var wrapper = $(".input_fields_wrap"); //Fields wrapper | |
var add_button = $(".add_field_button"); //Add button ID | |
var x = 1; //initlal text box count | |
$(add_button).click(function(e){ //on add input button click | |
e.preventDefault(); | |
if(x <= max_fields){ //max input box allowed | |
x++; //text box increment | |
$(wrapper).append("<div><select name='tournament_id_" + x + "'> <%=j(options_from_collection_for_select(Tournament.all.where(tour_id: 2), 'id', 'event'))%></select></div>")//add input box | |
// $(wrapper).append("<a href="javascript:void(0)" class="remove_field" data-id='"+x+"'>Remove</a></div>") | |
// <a href="javascript:void(0)" class="remove_field" data-id="' + x + '">Remove</a></div> | |
} | |
}); | |
// $wrapper.on("click", ".remove_field", function (e) { //user click on remove text | |
// id = $(this).attr('data-id'); | |
// $("#container_" + x).remove(); | |
// x--;});}); | |
var tournaments; | |
tournaments = $('#stake_tournament_id').html(); | |
return $('#stake_tour_id').change(function() { | |
var options, tour; | |
tour = $('#stake_tour_id :selected').text(); | |
options = $(tournaments).filter("optgroup[label= '" + tour + "']").html(); | |
if (options) { | |
return $('#stake_tournament_id').html(options); | |
} else { | |
return $('#stake_tournament_id').empty(); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment