ripplejs/ripple

Better iteration plugin

Opened this issue · 6 comments

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

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.

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

@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

@wryk Thank you for the prompt and helpful solution!

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.

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.