dimanche 4 octobre 2015

How communicate form inputs values in component with some controller?

i have this simple form in a EmberComponent:

<script type="text/x-handlebars" id="components/booking-box">
 <form>
  <label for="name"> First Name </label>
  <input id="name" type="text" />

  <input type="submit" value="Send" {{action 'send' }}/>
 </form>
</script>

And i have the JS:

SiteApp.BookingBoxComponent = Ember.Component.extend({
 actions: {
   send: function() {
     // crazy logic to manipulate the HTML
   }
 }
});

The form is very simple, but i'm manipulating the html of the form after send the name, that's why i need a component. The code for manipulate the html is not relevant here, right? That's why i'm not going to past.

And i have the controller:

SiteApp.BookingController = Ember.Controller.extend({
  create: function() {
    // I want access name here, is possible??
  }
});

Is possible access the value of the input name in the BookingController? And more important, how could i trigger the create method of the BookingController??

Aucun commentaire:

Enregistrer un commentaire