ripplejs / ripple

A tiny foundation for building reactive views
http://ripplejs.github.io
1.28k stars 66 forks source link

Better iteration plugin #4

Open anthonyshort opened 10 years ago

anthonyshort commented 10 years ago

The current each plugin was hacked together quickly. It's pretty gross.

anthonyshort commented 10 years ago

The current plugin is really only useful when the item themselves aren't views since changes to the values don't re-render the DOM.

We need something that can handle an array of views specifically and watches the array for changes. It would probably be a different plugin.

uipoet commented 10 years ago

A possibly related bug: <img src={{imageSource}}/> in the template being iterated causes a console.error when first initializing:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/{{imageSource}}

wryk commented 10 years ago

@uipoet It's a normal behaviour, when your browser process <img src={{imageSource}}/> he make a http request to http://localhost/{{imageSource}} and the server responds with an appropriate 404 status.

Better explanation : https://docs.angularjs.org/api/ng/directive/ngSrc

uipoet commented 10 years ago

@wryk Thank you for the prompt and helpful solution!

anthonyshort commented 10 years ago

Yeah you could make a directive that gets around it easily:

View.directive('data-src', function(value, el){
   el.src = value;
});

Might be worth me just including this in the library since it's tiny.

uipoet commented 10 years ago

Not a bad idea to bake it in. In my case, I've already made a component for photographs that now does this. I think the minimum to do would be update the README.md for the each plugin with this as the example. The current example led me to believe there was a bug.