first of all sorry for the title, couldn't think of anything real descriptive.
So here's the thing:
I have a site (kinda social-network) that have to list contact cards (little personal cards, with their info).
There are 2 versions of this cards: small and full. When you see a list of 10 contacts (for example), you'll see 10 small cards and when you click one of them, it should open the full card in a modal popup (I've chosen Simplemodal jQuery plugin for this).
I've created 2 partials: card_small
and card_full
. Both of them expect locals => :contact
So how would you do recommend doing this?
- Would you just render the 10 small cards along with their full version hidden and open the modal via jquery on sma开发者_运维技巧ll-card click?
- Would you just render the small cards to the browser and then make links_to_remote that returns the JS code that renders the full card partial?
Any other solution or rails plugin is welcome. I'm still starting with RoR =)
Generic form of the question: I need a way to have 2 partials (small and full) and when the small is clicked, the full one needs to be displayed in a modal dialog.
Thanks!
This is strictly a performance tradeoff. It's going to depend on how many cards you'll eventually have on the page. You don't want to go crazy and have 1000 copies of something you may not need, but if it's only 10, it's probably fine to have them hidden on the page. That way the response doesn't require another request to the server nor any delay.
I'd just load them straight up.
Sounds like there's no reason not to. Enacting the AJAX would just cause more database calls.
Edit: And like fullware said, if you have 1000 of them you'll probably need a different solution. At that point I'd just limit it to ~50 per page.
精彩评论