Hacker News new | ask | show | jobs
by jashkenas 5265 days ago
I'm quite sorry to agree with you -- there are a bunch of no-so-helpful Backbone tutorials floating around out there.

That said, most of the questions that we field that take the form: "Should I be doing X like Y in Backbone?" ... the answer is usually: Sure, that will work fine. In fact, there's a whole section in the FAQ about it:

http://backbonejs.org/#FAQ-tim-toady

Is there something in particular you're trying to figure out how to do?

1 comments

Complicated(?) template rendering. I have a template with varying sized elements, and a collection of images that I need to stuff into said template.

Not sure how to accomplish it, as I can't just iterate through the results as I need to put the right sized image into the right-sized grid (or scale it, which might be easier), but either way, I have four columns, some of which have either 1 or 2 rows, and each of the rows may be of different heights.

I know that there will always be seven elements in the template, and there are fixed heights that I can cheat with, but beyond that, I'm stumped.

Is the problem specific to rendering them with Backbone? If you always know the html/css solution, it's just a matter of picking one of the many js templating systems that works best. Of course, for very advanced manipulation, you can always just full back to writing a render method yourself and munging the nodes with jQuery.
Using a template library that allows arbitrary code will probably make this easier...

But it sounds like what you want to do is precompute all of the correct widths and heights for your elements, based on the image sizes. Then, when you go to render, you can simply look up the appropriate width, height, margin, padding for each cell.