Skip to content

Commit 4a9bdd8

Browse files
author
Alan Snow
committed
update scripts to work on dynamic content for datatables
1 parent b5a53c0 commit 4a9bdd8

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

tethysapp/streamflow_prediction_tool/public/js/manage_data_stores.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ var ERFP_MANAGE_DATA_STORES = (function() {
2929
* PRIVATE FUNCTION IMPLEMENTATIONS
3030
*************************************************************************/
3131
initializeTableFunctions = function() {
32+
$("#data_store_table").off();
33+
3234
$("#data_store_table").DataTable({
3335
destroy: true,
3436
columnDefs: [{
@@ -39,7 +41,7 @@ var ERFP_MANAGE_DATA_STORES = (function() {
3941
});
4042

4143
//handle the submit update event
42-
$('.submit-update-data-store').off().click(function(){
44+
$('#data_store_table').on("click", ".submit-update-data-store", function(){
4345
//clear messages
4446
$('#message').addClass('hidden');
4547
$('#message').empty()
@@ -72,7 +74,7 @@ var ERFP_MANAGE_DATA_STORES = (function() {
7274
});
7375

7476
//handle the submit delete event
75-
$('.submit-delete-data-store').off().click(function(){
77+
$('#data_store_table').on("click", '.submit-delete-data-store', function(){
7678
var data = {
7779
data_store_id: $(this).parent().parent().parent()
7880
.find('.data-store-id').text(),

tethysapp/streamflow_prediction_tool/public/js/manage_geoservers.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ var ERFP_MANAGE_GEOSERVERS = (function() {
3030
*************************************************************************/
3131

3232
initializeTableFunctions = function() {
33+
$("#geoserver_table").off();
34+
3335
$("#geoserver_table").DataTable({
3436
destroy: true,
3537
columnDefs: [{
@@ -40,7 +42,7 @@ var ERFP_MANAGE_GEOSERVERS = (function() {
4042
});
4143

4244
//handle the submit update event
43-
$('.submit-update-geoserver').off().click(function(){
45+
$('#geoserver_table').on("click", ".submit-update-geoserver", function(){
4446
//scroll back to top
4547
window.scrollTo(0,0);
4648
//clear messages
@@ -79,7 +81,7 @@ var ERFP_MANAGE_GEOSERVERS = (function() {
7981
});
8082

8183
//handle the submit delete event
82-
$('.submit-delete-geoserver').click(function(){
84+
$('#geoserver_table').on("click", ".submit-delete-geoserver", function(){
8385
var data = {
8486
geoserver_id: $(this).parent().parent().parent()
8587
.find('.geoserver-id').text()

tethysapp/streamflow_prediction_tool/public/js/manage_watershed_groups.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var ERFP_MANAGE_WATERSHED_GROUPS = (function() {
2828
* PRIVATE FUNCTION IMPLEMENTATIONS
2929
*************************************************************************/
3030
initializeTableFunctions = function() {
31+
$("#watershed_groups_table").off();
32+
3133
$("#watershed_groups_table").DataTable({
3234
destroy: true,
3335
columnDefs: [{
@@ -36,12 +38,13 @@ var ERFP_MANAGE_WATERSHED_GROUPS = (function() {
3638
}],
3739
order: [[ 3, "asc" ]]
3840
});
41+
3942
$(".watershed-select").each(function() {
4043
$(this).select2({placeholder: "Add Watershed to Group", width: '100%'});
4144
});
4245

4346
//handle the submit update event
44-
$('.submit-update-watershed-group').off().click(function(){
47+
$('#watershed_groups_table').on("click", '.submit-update-watershed-group', function(){
4548
//scroll back to top
4649
window.scrollTo(0,0);
4750
//clear messages
@@ -74,7 +77,7 @@ var ERFP_MANAGE_WATERSHED_GROUPS = (function() {
7477
});
7578

7679
//handle the submit delete event
77-
$('.submit-delete-watershed-group').off().click(function(){
80+
$('#watershed_groups_table').on("click", '.submit-delete-watershed-group', function(){
7881
var data = {
7982
watershed_group_id: $(this).parent().parent().parent().find('.watershed-group-id').text()
8083
};

tethysapp/streamflow_prediction_tool/public/js/manage_watersheds.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ var ERFP_MANAGE_WATERSHEDS = (function() {
398398
};
399399

400400
initializeTableFunctions = function() {
401+
$("#watershed_table").off();
402+
401403
$("#watershed_table").DataTable({
402404
destroy: true,
403405
columnDefs: [{
@@ -408,13 +410,13 @@ var ERFP_MANAGE_WATERSHEDS = (function() {
408410
});
409411

410412
//handle the submit edit event
411-
$('.submit-edit-watershed').off().click(function () {
413+
$('#watershed_table').on("click", ".submit-edit-watershed", function () {
412414
getModalHTML($(this).parent().parent().parent().find('.watershed-name').data('watershed_id'));
413415
});
414416

415417

416418
//handle the submit update event
417-
$('.submit-delete-watershed').off().click(function () {
419+
$('#watershed_table').on("click", ".submit-delete-watershed", function () {
418420
var data = {
419421
watershed_id: $(this).parent().parent().parent().find('.watershed-name').data('watershed_id')
420422
};

0 commit comments

Comments
 (0)