Ember Form Submission without controller


#1

Hi

I am new to ember and I am looking for a way to submit my form without the help of controllers because all the example I find on internet uses controllers for example a fiddle showing this : http://jsfiddle.net/mavilein/2VfJK/1/

Can you actualy help in form submission.


#2

Actions should bubble up to your routes if you are in a top level template.

Example:

Ember.Route.extend({
  actions: {
    submission() {
      console.log("handle form submission");
    }
  }
})

form:

<form {{action "submission" on="submit"}}>
  <button type="submit">Submit</button>
</form>

I hope this helps!

Ben


#3

There is also the route-action-helper: https://github.com/dockyard/ember-route-action-helper


#4

It’s probably a touch controversial but right now I am continuing to use controllers. Yes, they will be removed at some point but I don’t see that happening for a long time given how embedded they are in pretty much every app/addon.

I think that avoiding using them now actually feels more hacky and prone to issues than just doing things the “old way” and migrating at a later date if/when controllers are actually fully removed.

It doesn’t feel like removing controllers is a priority for the Ember team (and I agree with them) and trying to eliminate them is a lot of work and sometimes requires some very smelly code IMO.


#5

See they might remove or not remove them but Since there spec says that it should not be used whenever creating a new app I should avoid them.

Using them now is like adding to already existing problem of many app/add-on using them.

Thanks


#6

Not controversial at all. In fact, this is why they’re still around and the engineers making assumptions on what the future holds aren’t doing themselves a service.


#7

#8

I’d disagree for a few reasons:

  • Avoiding controllers is actually a lot of extra work right now
  • It rules out using some of the best Ember add-ons
  • If controllers are ever deprecated then there will be official guideliness on how to migrate from them which will most likely lead to better code than what you would have if you just try to avoid using them now.