Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$preventDefault - what for? #2

Open
ile opened this issue Sep 19, 2014 · 0 comments
Open

$preventDefault - what for? #2

ile opened this issue Sep 19, 2014 · 0 comments

Comments

@ile
Copy link

ile commented Sep 19, 2014

There is this function:

markup.on('element:form', function(template) {
  if (hasListenerFor(template, 'submit')) {
    addListener(template, 'submit', '$preventDefault($event)');
  }
});

https://github.com/derbyjs/derby-parsing/blob/master/lib/markup.js#L24-L28

Can I ask what would be the purpose of this? I'm running into a problem because of this -- I would not want to prevent the default action in all cases.

The case is like this:

A component has a <form> with on-submit="submit($event)" ... I'm passing that to the main app with this.emit(), and the main app catches it or not. If it doesn't catch it, I would like to perform the default action. Here's where I run into trouble -- the event is always prevented altough I would like to perform the default action sometimes.

I could try to find out if there are listeners in the main app (and if there are not, I could do form.submit() manually), but not sure if there is a way to do that. This wouldn't feel as clean though.

(I thought it would be better to ask it here on GitHub because this might be an "issue".)

ile added a commit to kantele/k-parsing that referenced this issue Nov 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant