Gazelle/static/functions/questions.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-10-13 08:01:01 +00:00
$(document).ready(function() {
$(".answer_link").click(function(e) {
e.preventDefault();
2013-10-18 08:00:55 +00:00
var id = this.id;
2013-10-13 08:01:01 +00:00
$("#answer" + id).gtoggle();
});
$(".submit_button").click(function(e) {
2013-10-18 08:00:55 +00:00
var id = this.id;
2013-10-13 08:01:01 +00:00
$.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();
2013-10-18 08:00:55 +00:00
var id = this.id;
var respDiv = $("#responses_for_" + id);
if (respDiv.length == 0) {
respDiv = $('<div id="responses_for_' + id + '" style="display: none; margin-left: 20px;"></div>');
$("#question" + id).after(respDiv);
2013-10-14 08:00:53 +00:00
$.ajax({
2013-10-18 08:00:55 +00:00
type : "GET",
2013-10-14 08:00:53 +00:00
url : "questions.php?action=ajax_get_answers",
dataType : "html",
data : {
"id" : id,
"userid" : $(this).data("gazelle-userid")
}
}).done(function(response) {
2013-10-18 08:00:55 +00:00
respDiv.html(response).show();
2013-10-14 08:00:53 +00:00
});
} else {
2013-10-18 08:00:55 +00:00
respDiv.toggle();
2013-10-14 08:00:53 +00:00
}
});
2013-10-13 08:01:01 +00:00
});