question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documented HTML hooks for JavaScript plugin authors

See original GitHub issue

In #981 I added data-column= attributes to the <th> on the table page. These should become part of Datasette’s documented API so JavaScript plugin authors can use them to derive things about the tables shown on a page (`datasette-cluster-map uses them as-of https://github.com/simonw/datasette-cluster-map/issues/18).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Dec 30, 2020

In terms of “places to put your plugin content”, the simplest solution I can think of is something like this:

<div id="plugin-content-pre-table"></div>

Alternative designs:

  • A documented JavaScript function that returns the CSS selector where plugins should put their content
  • A documented JavaScript function that returns a DOM node where plugins should put their content. This would allow the JavaScript to create the element if it does not already exist (though it wouldn’t be obvious WHERE that element should be created)
  • Documented JavaScript functions for things like “append this node/HTML to the place-where-plugins-go”

I think the original option - an empty <div> with a known id attribute - is the right one to go with here. It’s the simplest, it’s very easy for custom template authors to understand and it acknowledges that plugins may have all kinds of extra crazy stuff they want to do - like checking in that div to see if another plugin has written to it already, for example.

0reactions
simonwcommented, Jan 25, 2021

This is joined with #1191 now, which I’ve bumped from 0.54.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using JavaScript Hooks | Official ShopWP Plugin ...
ShopWP provides many different types of JavaScript hooks allowing you to customize various parts of the product and collection layout.
Read more >
JavaScript Hooks - Advanced Woo Search
JavaScript Hooks. Description of available plugin JavaScript actions and filters. Home · Documentation · Developers; JavaScript Hooks.
Read more >
backend_prod_layout — Shop-Script plugin hooks ... - Developers
DOCTYPE>, <HTML>, <HEAD>, and <BODY>. In this hook's handler, it is convenient to add plugin's CSS and JavaScript files using methods addCss() and...
Read more >
JavaScript Plugin Development and API - Gerrit Code Review
Gerrit provides a simple way for accessing the DOM via DOM hooks API. A DOM hook is a custom element that is instantiated...
Read more >
wordpress/hooks | Block Editor Handbook
In non-minified builds developers can register a filter or action that will be called on all hooks, for example: addAction( 'all', 'namespace', callbackFunction...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found