ajaxdiv
post some code
{% extends "base.html" %}
{% block body %}
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="ibox float-e-margins" style="z-index:9999;position: relative;">
<div class="ibox-title">
<h5>Custom responsive table </h5>
</div>
<div class="ibox-content">
<div class="row">
<select class="form-control m-b" name="group_name" id="group_id">
<option value=""></option>
{% for pro_i in pro_groups %}
<option value="{{ pro_i.id }}">{{ pro_i.group_name }}</option>
{% endfor %}
</select>
</div>
<div class="row">
<table class="table">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody id="ossfile-tab-body">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body" id="modal_userId"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"></button>
<button type="button" id="modal_user" class="btn btn-primary"></button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
{% endblock %}
{% block comm_js %}
<script type="text/javascript">
$("-sharpgroup_id").change(function () {
var group_id = $("-sharpgroup_id").val();
$.ajax({
data: {"group_id": group_id, csrfmiddlewaretoken: "{{ csrf_token }}"},
type: "POST",
url: "/pro1/gamebuild/" + group_id + "/",
success: function (data) {
var json_data = JSON.parse(data);
var content = "";
$.each(json_data, function (i, item) {
content += " <tr> <td>" + item.groupname + "</td> " +
"<td>" + item.game_name + "</td> " +
"<td><div class="font-bold">" +
"<button class="btn btn-info " id= \"+ item.id +\"version_value="trunk" type="button" onclick="Trunk(this)">" +
"<i class="fa fa-paste"></i> </button>" +
"<button class="btn btn-danger" id= "+ item.id +"version_value="branch" type="button" onclick="Branch(this)">" +
"<i class="fa fa-trash"></i> <span class="bold"></span></button>" +
"</div></td></tr>"
});
$("-sharpossfile-tab-body").html(content)
}
})
});
function Trunk(obj) {
var version_value = $(obj).attr("version_value");
var id = $(obj).attr("id");
{-sharpalert(version_value);-sharp}
$("-sharpmyModalLabel").html("");
$("-sharpmodal_userId").html(": " + version_value + " ?");
$("-sharpmyModal").modal("show");
}
</script>
{% endblock %}