复选框列表在翻页后原来页的选择被丢掉了
This commit is contained in:
parent
c8984e057a
commit
ecfee445c3
|
|
@ -95,7 +95,7 @@ class SubjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def append_to_stage
|
||||
@shixuns = Shixun.where(:id => params[:shixun_id])
|
||||
@shixuns = Shixun.where(:id => params[:choose_ids].split(",")).reorder("id desc")
|
||||
end
|
||||
|
||||
def publish
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@
|
|||
<%= javascript_heads %>
|
||||
<%= heads_for_theme %>
|
||||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/edu-popup','css/edu-common', "css/edu-public", 'css/taskstyle', 'css/edu-subject', 'css/moduel', 'css/font-awesome', 'css/edu-tooltipster', 'css/magic-check' %>
|
||||
<!-- MathJax的配置 -->
|
||||
<script type="text/javascript" src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<%= javascript_include_tag 'application', 'cookie',"avatars", 'header','prettify','attachments','edu/application','edu/subject' %>
|
||||
<%= call_hook :view_layouts_base_html_head %>
|
||||
<!-- page specific tags -->
|
||||
<%= yield :header_tags -%>
|
||||
|
|
@ -43,8 +46,5 @@
|
|||
<div id="ajax-modal" style="display:none;"></div>
|
||||
<%= call_hook :view_layouts_base_body_bottom %>
|
||||
</body>
|
||||
<!-- MathJax的配置 -->
|
||||
<script type="text/javascript" src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||||
<%= javascript_include_tag 'application', 'cookie',"avatars", 'header','prettify','attachments','edu/application' %>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
|
|
@ -39,4 +39,15 @@
|
|||
<a href="javascript:void(0);" class="task-btn task-btn-blue fr" onclick="submit_choose_course_shixun()">选择</a>
|
||||
<a href="javascript:void(0);" class="task-btn fr mr10" onclick="hideModal()">取消</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
if($("#choose_shixun_ids").val() != ""){
|
||||
var choose_ids = $("#choose_shixun_ids").val().split(",");
|
||||
for (var i = 0; i < choose_ids.length; i++){
|
||||
$("#shixun_input_" + choose_ids[i]).attr("checked", "checked");
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
<div class="task-popup-content">
|
||||
<div class="course-option">
|
||||
<%= form_for('new_form', :url => append_to_stage_subjects_path(), :remote => true, :method => "post", :html => {:id => 'choose_course_shixun_form'}) do |f| %>
|
||||
<input name="choose_ids" type="hidden" value="" id="choose_shixun_ids">
|
||||
<div class="clearfix" id="course_shixun_list">
|
||||
<%= render :partial => "course_shixun_list" %>
|
||||
</div>
|
||||
|
|
@ -15,14 +16,17 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
function submit_choose_course_shixun(){
|
||||
if($("input[name='shixun_id[]']:checked").length == 0){
|
||||
$("#lessong_nonechecked_tip").show();
|
||||
} else{
|
||||
$("#lessong_nonechecked_tip").hide();
|
||||
$("#choose_course_shixun_form").submit();
|
||||
$("#sx_none_notice").hide();
|
||||
hideModal();
|
||||
}
|
||||
}
|
||||
$("#course_shixun_list").on("click", "input[name='shixun_id[]']", function(){
|
||||
var choose_ids = $("#choose_shixun_ids").val() == "" ? [] : $("#choose_shixun_ids").val().split(",");
|
||||
if($(this).is(':checked')){
|
||||
choose_ids.push($(this).val());
|
||||
} else{
|
||||
choose_ids.splice($.inArray($(this).val(),choose_ids),1);
|
||||
}
|
||||
if(choose_ids.length != 0){
|
||||
$("#choose_shixun_ids").val(choose_ids.join(","));
|
||||
} else{
|
||||
$("#choose_shixun_ids").val('');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
function submit_choose_course_shixun(){
|
||||
if($("#choose_shixun_ids").val() == ""){
|
||||
$("#lessong_nonechecked_tip").show();
|
||||
} else{
|
||||
$("#lessong_nonechecked_tip").hide();
|
||||
$("#choose_course_shixun_form").submit();
|
||||
$("#sx_none_notice").hide();
|
||||
hideModal();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue