Boutran
Boutran

Reputation: 10124

How to get a handle on a EmberJS view when an other element is clicked

http://jsfiddle.net/maxl/aShMQ/4/

I have an Ember.TextField declared inlined within a template, inside the template is a button that has callback. I would like to be able to set the TextField.enabled=true when clicked. Since the template is a element in a collection, it is impossible to use an absolute path

Clicking on the edit icon in the JsFiddle example should illustrate what I am after

http://jsfiddle.net/maxl/aShMQ/4/

Upvotes: 0

Views: 189

Answers (2)

Musa
Musa

Reputation: 51

The pangratz above example is not working for ember 1.0 pre because content is passed to subview as "view". I made some modifications to it to work. See http://jsfiddle.net/musashimm/T9q6R/

Upvotes: 1

pangratz
pangratz

Reputation: 16163

Just bind the disabled of the Textfield to a property on your itemView, see http://jsfiddle.net/pangratz666/gXLXW/:

{{view Ember.TextField disabledBinding="isDisabled" valueBinding="content.v"}}
App.Items = Ember.CollectionView.create({
    itemViewClass: Ember.View.extend({
        templateName: 'itemView',
        isDisabled: true,
        __edit: function(evt) {
          this.toggleProperty('isDisabled');
          console.log(evt.get('content'))
        }
    })
});

Upvotes: 1

Related Questions