How to bind value form input select to attribute in controller

后端 未结 4 831
执笔经年
执笔经年 2020-12-16 05:10

I try to bind value from input select to attribute \"selectedValue\" in controller.

This is app.js

Food = Ember.Application.create();

Food.appsContr         


        
4条回答
  •  不知归路
    2020-12-16 05:24

    I'm not sure if this is of use to others, but I've been doing something similar based on the answers here, and have made this SelectView that should work in this context too. It binds to 'change', works out the view that is currently selected and then does something with its content.

    Food.SelectView = Ember.CollectionView.extend({
      change: function(e) {
        var selected = this.$().find(":selected").index();
        var content = this.get('childViews')[selected].content;
        // Do something with the result
        Food.appsController.set('selectedValue', content.title);
      }
    });
    

    This way you're able to pass around an object rather than the index of the select.

提交回复
热议问题