Skip to content

$preventDefault - what for?  #2

Open
@ile

Description

@ile

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".)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions