From cc03a2dcb0ebe85bbb36ecf2f553bea17f6411ee Mon Sep 17 00:00:00 2001 From: Jeremy Howard Date: Sun, 19 May 2024 03:05:04 +1000 Subject: [PATCH] target_id --- 01_components.ipynb | 8 ++++---- fasthtml/components.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/01_components.ipynb b/01_components.ipynb index c893ecfc..57af8899 100644 --- a/01_components.ipynb +++ b/01_components.ipynb @@ -107,15 +107,15 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 85, "id": "eb8a9099", "metadata": {}, "outputs": [], "source": [ "#| export\n", "def A(txt, hx_get, target_id=None, hx_swap=None, href='#', **kw):\n", - " if target_id: target_id = '#'+target_id\n", - " return xt('a', txt, href=href, hx_get=hx_get, hx_target=target_id, hx_swap=hx_swap, **kw)" + " if target_id: kw['hx_target'] = '#'+target_id\n", + " return xt('a', txt, href=href, hx_get=hx_get, hx_swap=hx_swap, **kw)" ] }, { @@ -306,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 86, "id": "d211e8e2", "metadata": {}, "outputs": [], diff --git a/fasthtml/components.py b/fasthtml/components.py index 2ac6e506..b2986bbc 100644 --- a/fasthtml/components.py +++ b/fasthtml/components.py @@ -20,8 +20,8 @@ def Hidden(value:str="", **kw): # %% ../01_components.ipynb 8 def A(txt, hx_get, target_id=None, hx_swap=None, href='#', **kw): - if target_id: target_id = '#'+target_id - return xt('a', txt, href=href, hx_get=hx_get, hx_target=target_id, hx_swap=hx_swap, **kw) + if target_id: kw['hx_target'] = '#'+target_id + return xt('a', txt, href=href, hx_get=hx_get, hx_swap=hx_swap, **kw) # %% ../01_components.ipynb 10 def set_val(tag, attr, val):