Skip to content
This repository was archived by the owner on May 30, 2021. It is now read-only.

Fix shared options between instances of DataTables#58

Open
Co-qn wants to merge 1 commit into
Mobius1:masterfrom
Co-qn:fix-shared-options
Open

Fix shared options between instances of DataTables#58
Co-qn wants to merge 1 commit into
Mobius1:masterfrom
Co-qn:fix-shared-options

Conversation

@Co-qn

@Co-qn Co-qn commented Mar 30, 2018

Copy link
Copy Markdown

Summary

When using multiple data tables in a HTML, it seems that options for each instances are shared.
I discover it is because of the defaultConfig object is broken changed when creating DataTable instances.

Example

var myData = {
    "headings": [
        "Name",
        "Company",
        "Ext.",
        "Start Date",
        "Email",
        "Phone No."
    ],
    "data": [
        [
            "Hedwig F. Nguyen",
            "Arcu Vel Foundation",
            "9875",
            "03/27/2017",
            "nunc.ullamcorper@metusvitae.com",
            "070 8206 9605"
        ],
        [
            "Genevieve U. Watts",
            "Eget Incorporated",
            "9557",
            "07/18/2017",
            "Nullam.vitae@egestas.edu",
            "0800 106980"
        ],
    ]
};

var table1 = new DataTable("#dt1", { data: myData, perPage: 25 });
var table2 = new DataTable("#dt2", { });

Expected

  • table1 has set default perPage = 25.
  • table2 has set default perPage = 10(default).
  • table1 has 2 records.
  • table2 has no records.

Actual(before fixed by this PR)

  • table1 has set default perPage = 25.
  • table2 has set default perPage = 25.
  • table1 has 2 records.
  • table2 has 2 records.

@johanneswilm

Copy link
Copy Markdown

@Co-qn Have you checked whether this is the only thing that is apparently leaking into the global namespace?
I wonder if it would be an idea to refactor the entire thing as ES2015+ modules. That should stop leakage (as well as make the sources more readable by spreading them out into several files).

@Mobius1

Mobius1 commented Mar 30, 2018

Copy link
Copy Markdown
Owner

@johanneswilm - The ES2015+ module route was something I was considering. Maybe it's time to put it in to action as the library seems to be fairly popular. I'll look into refactoring after the weekend.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants