Comments (9)
The last checked checkbox with a given name is the one that goes into params.
I didn't say this correctly. This will work for keys with an []
suffix, as @adam12 mentioned. Here is a fork of @davisums' CodePen that changes the [name]
to "status[]"
: https://codepen.io/triskweline/pen/rNbwMLj
from unpoly.
Unpoly autosubmits the form when the form's params ("form data") changes.
The checkboxes have the same [name]
. The last checked checkbox with a given name is the one that goes into params. Hence checking other boxes before "Won't do" does not change the form's params.
You can use different names, or radio buttons.
from unpoly.
Unpoly autosubmits the form when the form's params ("form data") changes.
The checkboxes have the same
[name]
. The last checked checkbox with a given name is the one that goes into params. Hence checking other boxes before "Won't do" does not change the form's params.You can use different names, or radio buttons.
It's a multiple-choice checkbox. I think that's the way those are typically rendered into HTML by both rails and django forms but I'll see if I can solve it some other way. Thanks for the help!
from unpoly.
It's a multiple-choice checkbox.
The [name]
of a multiple choice checkbox usually ends with a []
to signify to the browser and server that there are multiple values attached.
ex.
<input type="checkbox" name="status[]">
from unpoly.
The []
suffix is a convention shared by many, but not all web frameworks. There is no web standard for it AFAIK.
It would technically be possible to detect multi-selects without that suffix. However doing this would somewhat complicate the callback signature of up.watch()
and [up-watch]
. In particular the oldValue
and newValue
arguments would always need to be arrays, for the rare case that we're dealing with a multi-select field.
from unpoly.
I had wanted to test if it would work with brackets. Thanks for pointing that out.
My first solution was to use Alpine for autosubmit (since it's already a dependency on this project) but I ended going with this instead on Django:
post = request.POST.copy()
post.setlist("status", request.POST.getlist("status[]"))
form = FilterForm(post)
Since I don't want to use the form object to generate the HTML, this works fine in this case.
from unpoly.
Related Issues (20)
- snipcart with unpoly HOT 2
- Incorrect docs: Event target for 'up:form:submit' is not always the form HOT 5
- Is up-disable broken? HOT 2
- JS error when using up-submit: Uncaught up.Error: up.on(): The "up:click" callback function executeEmitAttr; EDIT: Putting the script in the end of body breaks the js HOT 2
- `up.animate` does not respect `duration: 0`
- Question: Async code in 'up:form:submit' possible race condition? HOT 2
- no transition with tailwindcss
- Web Component form field dropped by up-submit HOT 2
- Can unpoly exchange HTML fragments through WebSockets?
- Look at explicit port for cross-origin detection HOT 1
- Successfully submitting a form within a layer with the param up-layer='root' closes the layer with up:layer:dismiss and not up:layer:accept event HOT 1
- Handle links with anchors that start with a number HOT 1
- Handle links with anchors that start with a number HOT 1
- Browser does not loose it's zoom state between page navigations on smartphones HOT 2
- URLs with redundant slashes cause Unpoly to trigger a `DOMException` HOT 1
- HTML lang attribute is not updated on link follow HOT 1
- 3.8 up-defer shouldn't requires click HOT 7
- Unable to submit `up-accept` or `up-dismiss` links with the keyboard within popups
- Modal forms retain old values after editing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unpoly.