One of my buttons is not doing anything
One of my buttons is not doing anything

Below is the html for it. The only thing thats not working is the "btn-clone".
<?xml version="1.0" encoding="UTF-8" ?>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page"%>
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Restricted Entity Groups</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.0.1/css/searchBuilder.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.5/css/buttons.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.5/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.5/js/buttons.flash.min.js"></script>
<script src="https://cdn.datatables.net/searchbuilder/1.0.1/js/dataTables.searchBuilder.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.5/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.5/js/buttons.print.min.js"></script>
<link type="text/css" rel="stylesheet" href="../../css/default.css" />
</style>
<script>
$(function() {
var dataTableId = '#standard_datatable';
// Data Table
var table =$(dataTableId).DataTable({
sortTableByCol : 1,
dom: 'QBfrtip',
buttons: [
{
text: 'Add Restricted Entity Group',
<!--action: function ( e, dt, node, config ) { $( "#new_entry_form" ).modal('show');} -->
},
'copy', 'excel', 'pdf'
],
ajaxSource : "/cma/contents/screening/restrictedEntityGroup_data",
"columnDefs": [ {
"targets": 0,
"data": null,
"defaultContent": "<div align=center ><button onclick=openDataGroup() ><img src=../../css/images/164-glasses-2.png width=14px height= 8px></button><button><img type=button class=btn btn-primary btn-clone src=../../css/images/edit.gif width=14px height=8px></button><button><img src=../../css/images/delete.gif width=14px height= 8px></button></div>" } ]
});
// Handle click on "Edit" button
$('#standard-table').on('click', '.btn-clone', function(){
// Reset form
$('#new_entry_form').get(0).reset();
// Store current row
$('#standard_edit_dialog').data('row', $(this).closest('tr'));
// Show dialog
$('#standard_edit_dialog').modal('show');
});
// Handle modal shown event
$('#new_entry_form').on('shown.bs.modal', function (e){
// Get row data
var data = table.row($(this).data('row')).data();
// Set initial data
$('#standard_edit_dialog').val(data[0]).focus();
});
// Handle form submission event
$('#new_entry_form').on('submit', function (e){
e.preventDefault();
// Hide dialog
$('#standard_edit_dialog').modal('hide');
// Update table data
var row = $('#standard_edit_dialog').data('row');
var data = table.row(row).data();
data[0] = $('#edit-name').val();
table.row(row).data(data).invalidate();
// Refresh table
table.draw(false);
});
});
function openDataGroup(){
var restrictedEntityGroupName = $(this).parents('tr').children().eq(1).text();
window.location.href = resourceContext+"/contents/screening/restrictedEntityGroupDetails?groupName="+
restrictedEntityGroupName;
}
function changeType(){
var dataTableId = "#standard_datatable";
var selectedValue = document.getElementById("activateId").value;
$(dataTableId).dataTable().fnFilter(selectedValue , 2, true, false, false, false);
}
</script>
</head>
<body>
<div class="cma-toolmenu-widget">
<div class="breadCrumb" id="breadcrumb">
<ul>
<li>
<a href="${pageContext.request.contextPath}/">Home</a>
</li>
<li>
Restricted Entity Groups
</li>
</ul>
</div>
<div class="cma-toolmenu-section">
<div >
<LABEL style="margin-right: 44px;">Group Status: </LABEL>
<select id='activateId' onChange=changeType() style="font-size:11px;">
<option value="None"></option>
<option value="Active">Active</option>
<option value="Deactivated"> Deactivated</option>
</select>
<div id="datatableViewActive"></div>
</div>
</div>
</div>
<div class="standard-table">
<table class="display" id="standard_datatable">
<thead>
<tr>
<th title=""></th>
<th title="">Restricted Entity Group Name</th>
<th title="">Group Status</th>
<th title="">Group Last Updated</th>
<th title="">Group Created By </th>
<th title="">Group Created Date</th>
<th title="">Group Deactivated By</th>
<th title="">Group Deactivated Date</th>
</tr>
</thead>
</table>
</div>
<div id="standard_delete_dialog" class="ui-widget" title="Delete Restricted Entity Group" >
<p>Are you sure you wish to delete '<span id="row_id"></span>' Restricted Entity Group?</p>
</div>
<div id="standard_edit_dialog" title="Add Restricted Entity Group" class="cma-ui-form-dialog ui-helper-hidden">
<form id="new_entry_form" method="post">
<fieldset class="ui-widget-content">
<div class="ui-helper-clearfix hidden_edit hidden_view hidden_add">
<label for="Configuration_Name" >Original Restricted Entity Group Name: </label>
<input readonly="readonly" type="text" name="originalName" id="field0" class="text ui-widget-content ui-corner-all ui-state-disabled"/>
</div>
<div class="ui-helper-clearfix ui-helper-hidden" id="original">
<label for="name">Original Restricted Entity Group Name: </label>
<input type="text" disabled="disabled" name="name" id="original" value="" class="text ui-widget-content ui-corner-all hidden_edit hidden_view hidden_add"/>
</div>
<div class="ui-helper-clearfix">
<label for="groupName">Restricted Entity Group Name: </label>
<input required="required" type="text" name="groupName" id="field2" value="" maxlength="35" class="text ui-widget-content ui-corner-all novalue_clone" placeholder="Enter Name"/>
</div>
</fieldset>
</form>
</div>
<div id="status" title="Status"></div>
</body>
</html>
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This discussion has been closed.
Answers
I clicked "ask" button to fast. anyway I was trying to get the "standard_edit_dialog" popup to render and it never doesnt and I dont have any errors in consul. So not all hooks are in place and curious what i am missing?
You have
class=btn btn-primary btn-clone
. You need to put quotes around the classes, something like thisclass="btn btn-primary btn-clone"
.If you still need help please build a test case showing the issue so we canhelp debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin