diff --git a/docs/http.rst b/docs/http.rst index 799bac3..6c7c7c7 100644 --- a/docs/http.rst +++ b/docs/http.rst @@ -82,6 +82,9 @@ Response classes :param swap: How the response will be swapped into the target. + :param select: + Select the content that will be swapped from a response. + :param values: values to submit with the request. diff --git a/src/django_htmx/http.py b/src/django_htmx/http.py index 5996909..8a0fa49 100644 --- a/src/django_htmx/http.py +++ b/src/django_htmx/http.py @@ -61,6 +61,7 @@ def __init__( "none", None, ] = None, + select: str | None = None, values: dict[str, str] | None = None, headers: dict[str, str] | None = None, **kwargs: Any, @@ -78,6 +79,8 @@ def __init__( spec["target"] = target if swap is not None: spec["swap"] = swap + if select is not None: + spec["select"] = select if headers is not None: spec["headers"] = headers if values is not None: diff --git a/tests/test_http.py b/tests/test_http.py index 14707ec..267de2e 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -60,6 +60,7 @@ def test_success_complete(self): event="doubleclick", target="#main", swap="innerHTML", + select="#content", headers={"year": "2022"}, values={"banner": "true"}, ) @@ -73,6 +74,7 @@ def test_success_complete(self): "event": "doubleclick", "target": "#main", "swap": "innerHTML", + "select": "#content", "headers": {"year": "2022"}, "values": {"banner": "true"}, }