Skip to content

Instantly share code, notes, and snippets.

View EminenceHC's full-sized avatar

EminenceHC EminenceHC

  • Eminence Healthcare
  • Fresno CA
View GitHub Profile
@EminenceHC
EminenceHC / timecard.js
Created August 7, 2014 17:57
on load doesnt work but on change does
// THIS WORKS ON CHANGE
$("select.show-tick").on('change', function(){
if($(this).val()=== "82"){
$(this).closest('td').find('.number-of-students').show();
}
else {
$(this).closest('td').find('.number-of-students').hide();
}
@EminenceHC
EminenceHC / dtc.js
Last active August 29, 2015 14:04
jquery show closest div not all divs with class .number-of-students
// ON CHANGE SHOW/HIDE
$("select.show-tick").on('change', function(){
if($(this).val()== 84){
$(this).parent('td').find('.number-of-students').show();
}
else if($(this).val()== 85){
$(this).parent('td').find('.number-of-students').show();
}
else {
$(this).parent('td').find('.number-of-students').hide();
@EminenceHC
EminenceHC / routes.rb
Last active August 29, 2015 14:04
link_to to update_attribute
post '/tasks/toggle_complete' => 'tasks#toggle_complete'
resources :tasks
tasks_toggle_complete POST /tasks/toggle_complete(.:format) tasks#toggle_complete
@EminenceHC
EminenceHC / view.html.erb
Created July 23, 2014 21:47
Parameter Filter with simple_form
#TRYING TO PASS PARAMS TO THIS PATH BY DOING tasks_individual_view_path(my_param: x)
<%= simple_form_for(tasks_individual_view_path, method: 'get', html: { class: 'form-horizontal'}) do %>
<%= select_tag 'school_ids', options_for_select(@schools_id, params[:schools_id]), label: 'Projects', input_html: {class: 'multiselect', style: 'margin:0px 0px 5px 0px;', multiple: true} %>
<%= submit_tag 'Submit', :class => 'btn btn-primary', style: 'margin:5px 0px 5px 0px;' %>
<% end %>
@EminenceHC
EminenceHC / fields.html.erb
Created July 22, 2014 15:14
Default value of collection select.
# THIS IS WHAT I WANT BUT IT DOES NOT SHOW THE CURRENT VALUE IN THE SELECT
<%= f.input :task_id, collection: Project.where(id:[1, 2]), as: :grouped_select, group_method: :tasks, label: 'Task', input_html: {class: 'selectpicker show-tick form-horizontal'} %>
#THIS WILL SHOW THE CURRENT VALUE IN THE SELECT BUT DOES NOT DISPLAY THE SPECIFIC TASKS I WANT IN THE DISPLAY
<%= f.input :task_id, collection: Task.all, label: 'Task', input_html: {class: 'selectpicker show-tick form-horizontal'} %>
@EminenceHC
EminenceHC / timecard.js
Created July 14, 2014 23:58
Ignore non-number values during sum calculation
function calculateSum() {
var sum = 0;
$(".sum-hours").each(function() {
sum += parseFloat(this.value);
});
}
@EminenceHC
EminenceHC / timecard.js
Created July 11, 2014 16:31
Dynamically sum new values
$(".sum-hours").each(function() {
$(this).keyup(function(){
alert('pressed');
calculateSum();
});
});
function calculateSum() {
@EminenceHC
EminenceHC / list_view.html.erb
Created July 3, 2014 23:32
Query string format
<%= simple_form_for(daily_time_cards_list_view_path, :method =>'get') do |f| %>
<%= f.input :pay_period, as: :date_picker, label: 'Pay Period Start', required: false %>
<%= submit_tag 'Submit', :class => 'btn btn-primary', style: 'margin:5px 0px 5px 0px;' %>
<% end %>
@EminenceHC
EminenceHC / params.rb
Created July 3, 2014 20:55
Find param
{"utf8"=>"✓", "/daily_time_cards/list_view"=>{"pay_period"=>"2014-07-03"}, "commit"=>"Submit", "controller"=>"daily_time_cards", "action"=>"list_view"}
@EminenceHC
EminenceHC / ajax.js
Created June 19, 2014 16:58
ajax call not returning proper array
$.ajax({
type: "GET",
url: "/surveys/particular_users",
dataType: "JSON",
//Pass in each variable as a parameter.
data: {
particular_schools: ps,
particular_employees: pe
}