Skip to content

Commit

Permalink
Make posted data available to template tag. (bigskysoftware#835)
Browse files Browse the repository at this point in the history
Demo code:

```html
<form hx-post="/form?token=123" hx-target="#result">
    <input name="name" value="John Smith" />
    <select name="role">
        <option selected value="admin">Admin</option>
        <option selected value="author">Author</option>
        <option selected value="guest">Guest</option>
    </select>
    <button type="submit">Submit</button> 
</form>

<output id="result"></output>

<template url="/form">
    <div>${JSON.stringify(params)}</div>
</template>
```
  • Loading branch information
jreviews authored Feb 18, 2022
1 parent 6a91c29 commit 4edeae9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion www/js/demo/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function initMockRequests() {
{dynamicResponseModFn:
function(request, response, parameters) {
console.log(request, response, parameters)
return interpolate(elt.innerHTML, parameters);
return interpolate(elt.innerHTML, { ...parameters, ...Object.fromEntries(new URLSearchParams(request)) });
},
usePathnameForAllQueries: true});
}
Expand Down

0 comments on commit 4edeae9

Please sign in to comment.