Ember: prevent link-to from firing when an action within it is clicked

后端 未结 1 598
灰色年华
灰色年华 2021-01-24 12:14

I have a table where I want users to navigate to specific items when they click a row, but the row may contain other elements (such as checkboxes) that trigger actions but do

相关标签:
1条回答
  • 2021-01-24 12:52

    That works when you attach an action to an element, the input helper doesn't support action='foo' in that manner. It isn't even being hit at all.

    http://emberjs.jsbin.com/lugatite/1/edit

    You'll need to roll you're own checkbox, or just observe the checked value in your controller

    App.MyCheckBox = Ember.Checkbox.extend(Ember.TargetActionSupport, {
        target: Ember.computed.alias('controller'),
        action: 'save',
        actionContext: Ember.computed.alias('context'),
        click: function(el) {
          this.triggerAction(); 
          el.stopPropagation();
    
        }
    });
    

    http://jsbin.com/lugatite/5/edit

    0 讨论(0)
提交回复
热议问题