genenetwork / genenetwork2

GeneNetwork (2nd generation)
http://gn2.genenetwork.org/
GNU Affero General Public License v3.0
34 stars 24 forks source link

Bug fix on empty datatables #850

Closed jnduli closed 3 weeks ago

jnduli commented 3 weeks ago

Description

When a search returns 0 results, the console traceback shows a javascript error that we haven't handled. For example, when you visit the console.log of this page we see:

Uncaught TypeError: i is undefined
    jQuery 13
    loadDataTable https://cd.genenetwork.org/static/new/javascript/create_datatable.js:70
    create_table https://cd.genenetwork.org/static/new/javascript/create_datatable.js:3
    <anonymous> https://cd.genenetwork.org/gsearch?type=gene&terms=symbol:randomfacts:570
    jQuery 13

The fix disable the create_table function call when we don't have any results.

Testing

The datatable still works when we have results:

image

and when no results exists, we don't get the error now:

image

Review Notes

I can also make the change to https://github.com/jnduli/genenetwork2/blob/dd7268bc0c2d841779ba488b13ca0b1f0e9ea6bc/gn2/wqflask/templates/gsearch_pheno.html#L234 but I'm not too sure how to test this