def render_hidden_inputs( ids:TokenSelectorHtmlIds, # HTML IDs for this instance state:Optional=None, # current state oob:bool=False, # render with hx-swap-oob)->Any: # tuple of anchor and focus hidden inputs
Render hidden inputs for HTMX form submission.
build_include_selector
def build_include_selector( ids:TokenSelectorHtmlIds, # HTML IDs for this instance)->str: # CSS selector string for hx_include
Build a CSS selector for including anchor and focus inputs in HTMX requests.
from cjm_fasthtml_token_selector.core.models import TokenSelectorStatefrom cjm_fasthtml_token_selector.core.html_ids import TokenSelectorHtmlIdsids = TokenSelectorHtmlIds(prefix="ts0")state = TokenSelectorState(anchor=3, focus=7)inputs = render_hidden_inputs(ids, state)assertlen(inputs) ==2print("render_hidden_inputs test passed!")selector = build_include_selector(ids)assert"#ts0-anchor"in selectorassert"#ts0-focus"in selectorprint(f"Include selector: {selector}")print("build_include_selector test passed!")
render_hidden_inputs test passed!
Include selector: #ts0-anchor, #ts0-focus
build_include_selector test passed!