This notebook demonstrates widgets.jslink((a, 'value'), (b, 'value')) and widgets.jsdlink(...) between anywidgets in static export. The plugin (plugins/anywidget-static-export.mjs) detects LinkModel / DirectionalLinkModel entries in the notebook’s widget-state, attaches a page-level link manifest to the exported anywidget models, and lets the shared static host registry wire the bindings client-side as models register.
No connector widget is required — just call jslink / jsdlink like you would in a regular ipywidgets notebook.
import sys
import pathlib
sys.path.insert(0, str(pathlib.Path().absolute().parent))
import ipywidgets as w
from widgets.counter_widget import CounterWidgetBidirectional jslink between two CounterWidgets¶
Click +/− on either counter; the other follows.
c1 = CounterWidget(label='Counter A', widget_id='jslink_counter_a', value=0)
c2 = CounterWidget(label='Counter B', widget_id='jslink_counter_b', value=0)
display(c1)
display(c2)w.jslink((c1, 'value'), (c2, 'value'))One-way jsdlink between two CounterWidgets¶
jsdlink is the directional version of jslink: the source drives the target, but not the other way around. Click +/− on the leader and the follower mirrors it; clicks on the follower don’t propagate back.
Note on cross-library linking:
widgets.jslink((intslider, 'value'), (counter, 'value'))works in JupyterLab, but vanilla ipywidgets controls don’t have ESM bundles in static export — only anywidgets do. So in static export, both endpoints of ajslink/jsdlinkneed to be anywidgets.
leader = CounterWidget(label='Leader', widget_id='jsdlink_leader', value=0)
follower = CounterWidget(label='Follower', widget_id='jsdlink_follower', value=0)
display(leader)
display(follower)w.jsdlink((leader, 'value'), (follower, 'value'))