From 23b6c0a2329c589db2b121584abaa06abe0d60da Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 2 Oct 2020 15:42:17 -0500 Subject: Added function that pulls input data out of table and inserts it as hidden input elements in the form (so form submission can work with Scroller) * wqflask/wqflask/static/new/javascript/show_trait.js - Added function "get_table_contents_for_form_submit" that is called with submit_special (that is called for correlations and mapping from the trait page) --- .../wqflask/static/new/javascript/show_trait.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index a6f56d15..cde92160 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -499,6 +499,7 @@ edit_data_change = function() { return update_prob_plot(); } }; + show_hide_outliers = function() { var label; label = $('#show_hide_outliers').val(); @@ -509,6 +510,7 @@ show_hide_outliers = function() { return console.log("Should be now Hide Outliers"); } }; + on_corr_method_change = function() { var corr_method; corr_method = $('select[name=corr_type]').val(); @@ -523,10 +525,30 @@ on_corr_method_change = function() { $('select[name=corr_type]').change(on_corr_method_change); submit_special = function(url) { + get_table_contents_for_form_submit("trait_data_form"); $("#trait_data_form").attr("action", url); $("#trait_data_form").submit(); }; +get_table_contents_for_form_submit = function(form_id) { + // Borrowed code from - https://stackoverflow.com/questions/31418047/how-to-post-data-for-the-whole-table-using-jquery-datatables + let this_form = $("#" + form_id); + var params = primary_table.$('input').serializeArray(); + + $.each(params, function(){ + // If element doesn't exist in DOM + if(!$.contains(document, this_form[this.name])){ + // Create a hidden element + this_form.append( + $('') + .attr('type', 'hidden') + .attr('name', this.name) + .val(this.value) + ); + } + }); +} + var corr_input_list = ['corr_type', 'primary_samples', 'trait_id', 'dataset', 'group', 'tool_used', 'form_url', 'corr_sample_method', 'corr_samples_group', 'corr_dataset', 'min_expr', 'corr_return_results', 'loc_chr', 'min_loc_mb', 'max_loc_mb', 'p_range_lower', 'p_range_upper'] -- cgit v1.2.3