Skip to content

Commit

Permalink
Add select option to HttpResponseLocation class (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Anović authored and Nikola Anović committed Aug 1, 2024
1 parent 0e39c2d commit 3df0db0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/http.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions src/django_htmx/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_success_complete(self):
event="doubleclick",
target="#main",
swap="innerHTML",
select="#content",
headers={"year": "2022"},
values={"banner": "true"},
)
Expand All @@ -73,6 +74,7 @@ def test_success_complete(self):
"event": "doubleclick",
"target": "#main",
"swap": "innerHTML",
"select": "#content",
"headers": {"year": "2022"},
"values": {"banner": "true"},
}
Expand Down

0 comments on commit 3df0db0

Please sign in to comment.