Skip to content

Default option overwritten when mutliple JSONTable on same page #4

Description

@ydakilux

Hi,

I was 'playing with JSONTable' with 2 JSONTable on the same page but there was problems on the second table ( with the version you give me access to)

After tracing, I've seen that you are overwriting the defaultopts array.
I bypassed the problem by copying the array first. See code under.

var table = function(id,json,opts) { 
    ++tableCount;
    var targetdiv, columns, settings, table, thead, tbody, columnsJSON, tableAttrs; 
    columnsJSON = [];  
    targetdiv = document.getElementById(id); 

            var newdefaultopts = JSON.parse( JSON.stringify( defaultopts ) );
    settings = extend(newdefaultopts,opts)

    // send the whole array only if(deepScan):
    columns = (settings.deepScan) ? getColumns(json, settings) : getColumns([json[0]], settings); 

....

Thanks for your help last time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions