新建测验标题等内容时 点击取消应还原编辑框中的内容

This commit is contained in:
cxt 2015-11-25 10:38:43 +08:00
parent 3e0609afe3
commit 7fb78e4816
1 changed files with 12 additions and 5 deletions

View File

@ -3,9 +3,6 @@
<div>
<input name="exercise[exercise_name]" maxlength="100" id="exercise_name" class="testTitle mb10" type="text" placeholder="测验标题" value="<%=@exercise.exercise_name%>" />
</div>
<%# if edit_mode %>
<!--<label class="fl c_grey f14" style="margin-top: 4px;">发布日期(可选)</label>-->
<%# end %>
<label class="fl c_grey f14" style="margin-top: 4px;">截止时间:</label>
<div class="calendar_div fl">
<input type="text" name="exercise[end_time]" id="exercise_end_time" placeholder="截止时间" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>"/>
@ -23,10 +20,20 @@
<a class="btn_submit c_white" data-button="ok" onclick="pollsSubmit($(this));">
保存
</a>
<a class="btn_cancel" data-button="cancel" onclick="pollsCancel();">
<a class="btn_cancel" data-button="cancel" onclick="resetHead();pollsCancel();">
<%= l(:button_cancel)%>
</a>
</div>
<div class="cl"></div>
</div>
<% end %>
<script type="text/javascript">
function resetHead()
{
$("#exercise_name").val("<%=@exercise.exercise_name%>");
$("#exercise_end_time").val("<%= Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d") if exercise.end_time %>");
$("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>");
$("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>");
$("#exercise_description").val("<%=exercise.exercise_description %>");
}
</script>