Skip to content

{{#each}} attribute binding bug #497

Closed
etabard opened this Issue Feb 13, 2012 · 2 comments

3 participants

@etabard
etabard commented Feb 13, 2012

I tried to display an array of pictures with each.
The src binding fails and the this.get('src') returns a "String object".

Here is my code :

App = Ember.Application.create();

Em.Image = SC.View.extend({
    tagName: 'img',
    attributeBindings: ['src', 'alt'],
    didChangeSrc: function() {
        console.log(this.get('src'));
    }.observes('src')

})
App.test = ['http://laughingsquid.com/wp-content/uploads/fsm-google-doodle.png', 'http://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif'];
<script type="text/x-handlebars">
    {{#each App.pictures}}
       {{view Em.Image srcBinding="this" alt="no image"}}            
    {{/each}}

</script>


Exemple here : http://jsfiddle.net/Raildecom/8Rs5c/

Works outside of each : http://jsfiddle.net/justinbrown/8Rs5c/2/

@tchak
Ember.js member
tchak commented Feb 13, 2012

You can use this as a workaround for now

didChangeSrc: function() {
    this.set('src', String(this.get('src')));
}.observes('src')
@etabard
etabard commented Feb 13, 2012

Thanks for the quick workaround ;-)
It seems odd though !

@wagenet wagenet closed this in 03b685f Feb 14, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.