gpt4 book ai didi

javascript - Ember TextField valueBinding 到 Controller 问题

转载 作者:行者123 更新时间:2023-11-30 12:43:46 25 4
gpt4 key购买 nike

我正在使用 Twitter typeahead.js 插件。所以为了使用它,我扩展了 Ember 的 TextField。该插件一切正常。现在我只想让值在 Controller 内部可访问。

当我在 View 类中使用值绑定(bind)时,它工作正常。这是 bin example .此处的值最初设置并稍后更新。要测试 TextView 类型“aaa”。

App.TypeAhead = Ember.TextField.extend({      
classNames: ['cmp-typeahead'],
attributeBindings: ['id','value'],
valueBinding: 'targetObject.airportCode',
....
});

但是当我尝试通过模板设置值绑定(bind)时,它似乎不起作用。这是 bin example .要测试 TextView 类型“aaa”。

{{view App.TypeAhead data=airports valueBinding="view.targetObject.airportCode" 
id="fromAirportCode"}}

我做错了什么?

最佳答案

因为 View 助手会保留当前的 Controller ,所以很简单:

{{view App.TypeAhead data=airports valueBinding="airportCode" 
id="fromAirportCode"}}

示例:http://emberjs.jsbin.com/ciwiv/1/edit

关于javascript - Ember TextField valueBinding 到 Controller 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23391595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com