-
Notifications
You must be signed in to change notification settings - Fork 11
Replaced Rails loop with JavaScript map to handle instructor merges #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,23 +4,26 @@ | |
|
||
<script type="text/javascript"> | ||
profname = function(prof) { return prof.name; } | ||
|
||
$(document).ready( function() { | ||
$.ajax({ url: <%= raw coursesurveys_instructor_ids_path.inspect %>, | ||
success: function(data) { | ||
<%-[0,1].each do |i|-%> | ||
$('#ibox<%=i%>'). | ||
autocomplete(data, {formatItem: profname} ). | ||
result( function(event,item) { | ||
$('#id_<%=i%>')[0].value = item.id; | ||
$('#ibox<%=i%>')[0].disabled = true; | ||
}); | ||
$('#ibox<%=i%>').keypress(function(event){if(event.which == 13) event.preventDefault();}); | ||
<%-end-%> } | ||
}); | ||
$("#submit").click( function() { | ||
}); | ||
|
||
$.ajax({ | ||
url: <%= raw coursesurveys_instructor_ids_path.inspect %>, | ||
success: function(data) { | ||
[0,1].map(function(i) { | ||
$('#ibox' + i).autocomplete(data, {formatItem: profname}).result(function(event, item) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would then become |
||
$('#id_' + i)[0].value = item.id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If element with the $(this).parent().find('.instructor-id').attr('value', item.id); |
||
$('#ibox' + i)[0].disabled = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely use $(this).attr('disabled', true); |
||
}); | ||
$('#ibox' + i).keypress(function(event) { | ||
/* Prevent return button from submitting form */ | ||
if (event.which == 13) { | ||
return false; | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
}); | ||
</script> | ||
|
||
<style type="text/css"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah...maybe this wasn't the best way of curing the problem. We might as well jQuery all the way.
Instead of using the ID selectors, a class applied to the inputs and the hidden fields might be a better idea. Say the fields currently id'd as
iboxN
had the classinstructor-name
. You could then write: