From afbf62fd646e3d12bf543d7251ca1b0d84702f7c Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 1 Jul 2016 17:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E8=AF=BE=E7=A8=8B=E6=95=B0=E4=B8=BA0?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_syllabus_list.html.erb | 35 +++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/app/views/users/_user_syllabus_list.html.erb b/app/views/users/_user_syllabus_list.html.erb index 3cc7bf61c..b5bd7d481 100644 --- a/app/views/users/_user_syllabus_list.html.erb +++ b/app/views/users/_user_syllabus_list.html.erb @@ -94,23 +94,26 @@ $(".syllabus_courses_list").each(function(){ var syStaust = $(this).children(":first-child"); + var classNum = $(this).next().children().children("li").size(); - if (syStaust.hasClass("sy_courses_open")){ - $(this).toggle(function(){ - $(this).next().hide(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); - },function(){ - $(this).next().show(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); - }); - }else{ - $(this).toggle(function(){ - $(this).next().show(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); - },function(){ - $(this).next().hide(); - $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); - }); + if(classNum>0){ + if (syStaust.hasClass("sy_courses_open")){ + $(this).toggle(function(){ + $(this).next().hide(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + },function(){ + $(this).next().show(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + }); + }else{ + $(this).toggle(function(){ + $(this).next().show(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_open").removeClass("icons_sy_close"); + },function(){ + $(this).next().hide(); + $(this).children(":first-child").children(":first-child").addClass("icons_sy_close").removeClass("icons_sy_open"); + }); + } } }); });