fix for js

This commit is contained in:
Harry Bomrah 2015-01-08 19:46:45 +08:00
parent 70644e2739
commit a49fdecb57
2 changed files with 54 additions and 31 deletions

View File

@ -30,11 +30,11 @@
<a class="btn btn-small btn-danger action-btns" data-id="<%= rm.id.to_s %>" href="/admin/admin_modules/uninstall_site_list?id=<%= rm.id.to_s %>" for="uninstallation">Uninstall</a>
<a class="btn btn-small btn-warning action-btns" data-id="<%= rm.id.to_s %>" href="/admin/admin_modules/revokelist?id=<%= rm.id.to_s %>" for="revoke_access">Revoke Access</a>
<a class="btn btn-small btn-success action-btns" data-id="<%= rm.id.to_s %>" href="/admin/admin_modules/grantlist?id=<%= rm.id.to_s %>" for="grant_access">Grant Access</a>
<a class="btn btn-small" href="/admin/admin_modules/approve?module_id=<%= rm.id.to_s %>" data-toggle="modal" data-target="#editModal">Edit</a>
<a class="btn btn-small edit-btn" href="/admin/admin_modules/approve?module_id=<%= rm.id.to_s %>">Edit</a>
</td>
<% else %>
<td>
<a class="btn btn-small btn-primary" href="/admin/admin_modules/approve?module_id=<%= rm.id.to_s %>" data-toggle="modal" data-target="#approveModal">Approve</button>
<a class="btn btn-small btn-primary aprrove-btn" href="/admin/admin_modules/approve?module_id=<%= rm.id.to_s %>">Approve</button>
</td>
<% end %>
</tr>

View File

@ -42,36 +42,17 @@
</div>
</div>
<script type="text/javascript">
$("#approveModuleBtn").on("click",function(){
$("#approveSiteForm").ajaxSubmit({
success : function(){
$.ajax({
"url" : "/admin/admin_modules",
"dataType" : "html",
"type" : "get"
}).done(function(data){
$("#index_table").html(data);
$("#approveModal").modal("hide");
bindHandlers();
})
}
var updateTableData = function(){
$.ajax({
"url" : "/admin/admin_modules",
"dataType" : "html",
"type" : "get"
}).done(function(data){
$("#index_table").html(data);
bindHandlers();
})
})
$("#editModuleBtn").on("click",function(){
$("#approveSiteForm").ajaxSubmit({
success : function(){
$.ajax({
"url" : "/admin/admin_modules",
"dataType" : "html",
"type" : "get"
}).done(function(data){
$("#index_table").html(data);
$("#editModal").modal("hide");
bindHandlers();
})
}
})
})
}
var bindHandlers = function(){
var actionsModal = $("#actionsModal");
var btn_type = null;
@ -147,7 +128,49 @@
actionsModal.find(".modal-header h3").text(title);
$("#submitModalBtn").text(btn_title);
}
$(".edit-btn").on("click",function(){
var el = $(this);
$.ajax({
"url" : el.attr("href"),
"type" : "get",
"dataType" : "html"
}).done(function(form){
$("#editModal .modal-body").html(form);
$("#editModal").modal("show");
$("#editModal #editModuleBtn").on("click",function(){
$("#approveSiteForm").ajaxSubmit({
success : function(){
updateTableData();
$("#editModal").modal("hide");
}
})
})
})
return false;
})
$(".approve-btn").on("click",function(){
var el = $(this);
$.ajax({
"url" : el.attr("href"),
"type" : "get",
"dataType" : "html"
}).done(function(form){
$("#approveModal .modal-body").html(form);
$("#approveModal").modal("show");
$("#approveModal #approveModuleBtn").on("click",function(){
$("#approveSiteForm").ajaxSubmit({
success : function(){
updateTableData();
$("#approveModal").modal("hide");
}
})
})
})
return false;
})
}
bindHandlers();
</script>