Hacker News new | ask | show | jobs
by bmelton 5265 days ago
Thank you.

As a backend developer trying to embrace Backbone, I'm finding that there isn't a wealth of consistently good material to learn from. One tutorial will push everything to the view, and the next pushes everything to the router.

It's hard to determine exactly what the best practices are, and making up my own mind isn't necessarily that informed, as I'm just learning the framework.

I'm hoping for more and more documentation to appear as there are things that I simply can't figure out how to do and can't find a reference for anywhere. Every resource helps.

2 comments

Best resources I've found on backbone are articles from Derick Bailey at LosTechies.com

http://lostechies.com/derickbailey/

Unfortunately, this site has gone dark for the day due to the SOPA protest. Will have to check this out once it comes back up.
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?

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.