Gazelle/static/functions/questions.js

47 lines
999 B
JavaScript
Raw Normal View History

2013-10-13 08:01:01 +00:00
$(document).ready(function() {
2013-10-14 08:00:53 +00:00
var open_responses =
2013-10-13 08:01:01 +00:00
$(".answer_link").click(function(e) {
e.preventDefault();
id = this.id;
$("#answer" + id).gtoggle();
});
$(".submit_button").click(function(e) {
id = this.id;
$.ajax({
type : "POST",
url : "questions.php?action=take_answer_question",
data : {
"auth" : authkey,
"id" : id,
"answer" : $("#replybox_" + id).val()
}
}).done(function() {
$("#question" + id).remove();
$("#answer" + id).remove();
2013-10-14 08:00:53 +00:00
$("#responses_for_" + id).remove();
2013-10-13 08:01:01 +00:00
});
});
2013-10-14 08:00:53 +00:00
$(".view_responses").click(function(e) {
e.preventDefault();
id = this.id;
if ($("#responses_for_" + id).length == 0) {
$.ajax({
type : "POST",
url : "questions.php?action=ajax_get_answers",
dataType : "html",
data : {
"id" : id,
"userid" : $(this).data("gazelle-userid")
}
}).done(function(response) {
$("#question" + id).after(response);
});
} else {
$("#responses_for_" + id).remove();
}
});
2013-10-13 08:01:01 +00:00
});