1 {% load url from future %}
6 // Assumes variable csrf_token is made available
7 // by embedding document
9 beforeSend: function(xhr, settings) {
10 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
11 // Only send the token to relative URLs i.e. locally.
12 xhr.setRequestHeader("X-CSRFToken", '{{ csrf_token }}');
20 $("#str_school").autocomplete({
21 source: function(request, response){
23 url: "{% url 'json_school_list' %}",
24 data: {q: request.term},
25 success: function(data) {
27 if (data['status'] === 'success') {
28 response($.map(data['schools'], function(item) {
36 // FIXME: do something if school not found
37 $('#create_school_link').show();
44 select: function(event, ui) {
45 console.log("select func");
47 console.log(ui.item.value);
49 console.log(ui.item.label);
50 // set the school id as the value of the hidden field
51 $('#id_school').val(ui.item.real_value);
52 // set the School name as the textbox field
53 //$('#str_school').val(ui.item.label);
61 <section id="add-course" class="modal_content">
62 <form method="POST" action="{% url 'api_course_post' %}">
65 <div class="eight columns centered lightbox_modal" style="margin-top: 121px;">
67 <div class="lightbox_header modal_header twelve columns">
69 </div><!-- /modal_header -->
72 <div class="row lightbox_row">
73 <div class="seven columns centered">
74 <label class="lightbox_label">
76 </label><!-- lightbox_label -->
77 <div class="lightbox_field">
78 <input id="str_school" class="lightbox_textfield" type="text" name="str_school"/>
79 <input id="id_school" name="school" type='hidden'/>
80 </div><!-- .lightbox_filed -->
82 </div> <!-- .row .lightbox_row -->
85 <div class="row lightbox_row">
86 <div class="seven columns centered">
87 <label class="lightbox_label">
89 </label><!-- lightbox_label -->
90 <div class="lightbox_field">
91 <input id="id_name" class="lightbox_textfield" type="text" name="name" maxlength="255" />
92 </div><!-- .lightbox_filed -->
94 </div> <!-- .row .lightbox_row -->
96 <div class="row lightbox_row">
97 <div class="seven columns centered">
98 <label class="lightbox_label">
100 </label><!-- lightbox_label -->
101 <div class="lightbox_field">
102 <input id="id_instructor_name" class="lightbox_textfield" type="text" name="instructor_name" maxlength="75" />
103 </div><!-- .lightbox_filed -->
105 </div> <!-- .row .lightbox_row -->
107 <div class="row lightbox_row">
108 <div class="seven columns centered">
109 <label class="lightbox_label">
111 </label><!-- lightbox_label -->
112 <div class="lightbox_field">
113 <input id="id_instructor_email" class="lightbox_textfield" type="text" name="instructor_email" maxlength="75" />
114 </div><!-- .lightbox_filed -->
116 </div> <!-- .row .lightbox_row -->
118 <div class="row lightbox_row">
119 <div class="seven columns centered">
120 <label class="lightbox_label">
122 </label><!-- lightbox_label -->
123 <div class="lightbox_field">
124 <textarea id="id_desc" class="lightbox_textfield lightbox_textarea" rows="4" cols="40" name="desc"></textarea>
125 </div><!-- .lightbox_filed -->
127 </div> <!-- .row .lightbox_row -->
129 <div class="row lightbox_row">
130 <div class="seven columns centered">
131 <label class="lightbox_label">
132 </label><!-- lightbox_label -->
133 <div class="lightbox_field">
134 <button class="lightbox-button" id="submit-lightbox-create-course" type="submit">CREATE COURSE</a>
135 </div><!-- .lightbox_filed -->
137 </div> <!-- .row .lightbox_row -->
139 <div class="lightbox_close"></div>
141 </div> <!-- .lightbox_modal -->
145 </section><!--add_course_content-->