• Resolved Aniket

    (@aniketdumbare)


    Hello,

    How to use getElementById() with tablepress tables? Today we observed that, on a page the table we had added, the table id which was being generated till yesterday (for last 6 months) was tablepress-<ID>-no-2 however all of a sudden today it started having id tablepress-<ID> only.

    On our page, we always had any such table only once and it was never used twice neither on the page nor on whole website. https://tablepress.org/documentation/ for tablepress-<ID>-no-<number> describes the scenario.

    However we never had such case. Which ID we should rely on to be used with getElementById()

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Well, you would have to use the HTML that your table has on the page.

    Normally, that is tablepress-<ID>. If the table has the HTML ID tablepress-<ID>-no-2 (or higher numbers), this means that its rendering function has been called twice (or even more often). To not duplicate HTML IDs (as these need to unique), that -no-... is appended. Besides embedding a table on the same page twice (on purpose), this can e.g. happen if other plugins already (pre-)process the post/page content for whatever reason, before it is actually rendered.

    (An alternative approach here, to be independent from the actual HTML ID, might be to check if the JavaScript code that you are running can be implemented as part of a “Custom Command”. In that, DataTables hooks, like https://datatables.net/reference/option/initComplete are available, which can also be used for post-processing, for example.)

    Best wishes,
    Tobias

    Thread Starter Aniket

    (@aniketdumbare)

    Thank you! Let me check.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    sure! If there’s anything needed here from me, let me know.

    Best wishes,
    Tobias

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘getElementById(table_id)’ is closed to new replies.