Last active
December 26, 2015 17:39
-
-
Save atstockland/7188314 to your computer and use it in GitHub Desktop.
This file contains 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
<div class="well top_box"> | |
<h3>LESSON</h3> | |
<%= f.association :flightlesson %> | |
<div id="load_box"> | |
<p id="gradable_items"></p> | |
<p id="scenarios"></p> | |
</div> | |
</div> |
This file contains 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
def gradable_items_inputs | |
@lesson = Flightlesson.find(params[:lesson]) | |
@graded_items = GradedItem.new | |
@subjects = GradableSubject.all | |
@grade_scale = current_school.gradescales.in_use.grade_scale_items.order("grade asc").collect{ |g| [g.name, g.grade] } | |
end |
This file contains 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
jQuery -> | |
# ready = -> | |
f_lesson = $("#flight_flightlesson_id") | |
gi_container = $("#gradable_items_container") | |
load_box = $("#load_box") | |
lesson_tell = $("#load_box #gradable_items") | |
scenario_tell = $("#load_box #scenarios") | |
get_data = -> | |
if $('#flight_flightlesson_id option[value]:selected').text() == '' | |
gi_container.text("You must select a lesson in the 'Flight Info' Tab") | |
scenario_tell.text("") | |
load_box.removeClass("is-fetching") | |
lesson_tell.text "No Lesson Selected" | |
else | |
$.ajax | |
url: "gradable_items_inputs?lesson=#{ f_lesson.val() }" | |
beforeSend: -> | |
load_box.addClass("is-fetching") | |
lesson_tell.text("...loading gradable items") | |
scenario_tell.text("...loading scenarios") | |
success: (data) -> | |
gi_container.html(data).find("#ajax_gradable_items_for_lesson_content") | |
complete: -> | |
lesson_tell.text("") | |
scenario_tell.text("") | |
load_box.removeClass("is-fetching") | |
error: -> | |
lesson_tell.text "ERROR" | |
# get_data() # if this is un-commented...it runs over and over and over and over | |
f_lesson.on "change", -> | |
get_data() |
This file contains 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
<div id="gradable_items_container"> | |
// form inputs from tempate are loaded in here via AJAX | |
</div> |
This file contains 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
// this template is hit when the lesson_id input is changed | |
// this content is then loaded into the nested form into div#gradable_items_container | |
<div id="ajax_gradable_items_for_lesson_content"> | |
<% @subjects.each do |subject| %> | |
<% unless lessons_gradable_items(subject, @lesson).blank? %> | |
<%= subject.name %> | |
<%= simple_fields_for @graded_items do |graded_item| %> | |
<% lessons_gradable_items(subject, @lesson).each do |gradable_item| %> | |
<%= gradable_item.name %> | |
<%= graded_item.input :gradable_item_id, as: :hidden %> | |
<%= graded_item.input :cfi_grade, collection: @grade_scales %> | |
<%= graded_item.input :pt_grade, collection: @grade_scales %> | |
<% end %> <%# lessons_gradable_items %> | |
<% end %> <%# fields_for %> | |
<% end %> <%# unless not in subject %> | |
<% end %> <%# GradableSubject %> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment