有没有办法从ember.js注入的把手模板剥离绑定标签?我希望能够提取没有任何metamorph script
标签的html。Ember.js地带绑定标签
我有这个related question,但也想问这个更一般的问题。
有没有办法从ember.js注入的把手模板剥离绑定标签?我希望能够提取没有任何metamorph script
标签的html。Ember.js地带绑定标签
我有这个related question,但也想问这个更一般的问题。
如果有人需要这个功能,我创建了一个小的jQuery插件做到这一点:
# Small extension to create a clone of the element without
# metamorph binding tags and ember metadata
$.fn.extend
safeClone: ->
clone = $(@).clone()
# remove content bindings
clone.find('script[id^=metamorph]').remove()
# remove attr bindings
clone.find('*').each ->
$this = $(@)
$.each $this[0].attributes, (index, attr) ->
return if attr.name.indexOf('data-bindattr') == -1
$this.removeAttr(attr.name)
# remove ember IDs
clone.find('[id^=ember]').removeAttr('id')
clone
还是希望有一个更好的办法。
您可以使用unbound
把手助手在单个属性级别执行此操作。
有上#unbound
块帮手,这将是你想要做什么漂亮的正在做的工作:https://github.com/emberjs/ember.js/pull/321
另一种方法是,在你的意见,指定一个普通的把手模板。没有一个输出会被绑定。
App.UnboundView = Ember.View.extend({
template: Handlebars.compile("output is: {{msg}} here"),
msg: "not bound"
});
这里有一个的jsfiddle例如:http://jsfiddle.net/ebryn/zQA4H/
这里有一个更好的办法
{{unbound propertyName}}
http://emberjs.com/api/classes/Ember.Handlebars.helpers.html#method_unbound
你碰巧知道是否有在灰烬的新版本更好的办法? – Denzo 2013-03-07 05:09:57