Option to prevent default in domSource.select().events()
See original GitHub issueCycle allows turning virtually any DOM event into a stream to be consumed by intents. However, for some events this proves pointless as the event’s default handling is disruptive.
For example, suppose I have a form and would like to receive a stream of submissions on it, I could do something such as:
Cycle.h('form#search', {onsubmit: 'searchSubmits$'}, [
Cycle.h('input#q', {autocomplete: 'off', name: 'query', type: 'text', placeholder: 'Add term'})
])
While this would indeed create a stream, the form would still actually navigate to its target upon submission, thus denying me the ability to make sensible use of the stream.
What I would like to have (and will gladly make a reality) is something like this:
Cycle.h('form#search', {onsubmit: 'searchSubmits$!'}, [
Cycle.h('input#q', {autocomplete: 'off', name: 'query', type: 'text', placeholder: 'Add term'})
])
Which will basically retain the same behavior, except it will also call preventDefault
for the submit event, allowing use of the stream.
I am, of course, entirely open to suggestions on how to actually signify this behavior. Being a Ruby buff I am all for adding bangs to the end of things to signify anything drastic, but this is not necessarily the best way.
Issue Analytics
- State:
- Created 9 years ago
- Comments:25 (23 by maintainers)
Top GitHub Comments
Why don’t we make it an optional argument to events?
DOM.select('.add').events('click', {preventDefault: true})
Sure thing @grozen, have a go. I will review your pull request and help you get it merged. 🙂 👍