add javascript to auto-scroll down to form if there are errors
authorSeth Woodworth <seth@sethish.com>
Wed, 27 Mar 2013 21:51:23 +0000 (17:51 -0400)
committerSeth Woodworth <seth@sethish.com>
Wed, 27 Mar 2013 21:51:23 +0000 (17:51 -0400)
karmaworld/templates/courses/course_list.html

index e8d9ecdd780c73e983e17b47130772fffa33c71a..cc18a4b08c2f1848a23c80ad6bd5d6a1d96a4e43 100644 (file)
 {% endblock %}
 
 {% block pagescripts %}
-<script src="{{ STATIC_URL }}js/bootstrap-modal.js" ></script>
 <script src="{{ STATIC_URL }}js/jquery.dataTables.js"></script>
 <script>
 $(document).ready(function() {
+  // If there were form errors, open the form and jump to it
+  var jump_to_form = {% if jump_to_form %}true{% else%}false{% endif %};
+  if (jump_to_form) {
+    $("#add-course-form").show();
+    $('#add-course-btn').hide();
+    document.getElementById('add-course-form').scrollIntoView(true);
+  }
+
+
+  // load dataTable for course data
   $('#course_list').dataTable({
     // remove the default filter label
     'oLanguage': {