Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:33:02+00:00 2026-06-11T02:33:02+00:00

Lets take for example the following template: <div class=picture> <img src=<%= model.get(url) %>></img> <p

  • 0

Lets take for example the following template:

<div class="picture">
    <img src="<%= model.get("url") %>"></img>
    <p class="author"><%= model.get("author") %></p>
    <p class="date"><%= model.get("date") %></p>
    <div class="likers"><%= some logic that outputs a nice list of people that have liked this picture %></div>
    <button class="like-button <%= model.get("is_liked") ? 'active' : '' %>"><%= model.get("is_liked") ? 'You liked this picture' : 'Click here to like this picture' %></button>
</div>

Lets say I render that template using Backbone and clicking the like-button triggers the following function:

Option A:

var me = "Peeter";
var model; //refrence to the model 

var likers = model.get("likers");

model.get("is_liked") ? likers.remove(me) : likers.add(me); //Add/remove me
model.set({
    "is_liked" : !model.get("is_liked"), //Toggle state
    likers : likers
}); 

var $button = $(".like-button")
var $likers = $(".likers");

$button.toggleClass("active");
$button.hasClass("active") ? $button.text('You liked this picture') ? $button.text('Click here to like this picture');

$likers.text(/* copy/paste the logic that's in the  template to render the list of likers*/);

Option B:

var me = "Peeter";
var model; //refrence to the model 
var template; //refrence to the template declared at the top of this question

var likers = model.get("likers");

model.get("is_liked") ? likers.remove(me) : likers.add(me); //Add/remove me
model.set({
    "is_liked" : !model.get("is_liked"), //Toggle state
    likers : likers
}); 

template.render();

Which one of the methods would you recommend? Why? Also please take into count a mobile browser, is re-rendering an entire template (if the template was a bit bigger) a bit too slow on a mobile device?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:33:04+00:00Added an answer on June 11, 2026 at 2:33 am

    This is a question that cannot be answered in general and some profiling for your specific use case will certainly help.

    But as a general answer I think you have to review to following points:

    1. Size of the template and the resulting time to process it with data
    2. Number of events that you bind to your view. The more, the more you need to bind and unbind with every re-rendering
    3. Your render function and how you have set it up as significant influence.

    For more detais, please check these links:

    • http://ianstormtaylor.com/break-apart-your-backbonejs-render-methods/
    • http://ianstormtaylor.com/assigning-backbone-subviews-made-even-cleaner/
    • http://ianstormtaylor.com/rendering-views-in-backbonejs-isnt-always-simple/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To make thing easier to understand lets take the following example: I want to
Let's take for example a single file committed in CVS with the following history.
Lets take stackoverflow as an example: Post Postid Title Mess -------------------------------------------------- 1 Title1 This
I'm working on a data model for SIP routing information. Let's take as example
OK. So, let's take PHP as an example. I'm entering a URL in the
Is it possible to generate comments for closing div tags, lets take this ex.
Lets take a look at the following code: mongodb.js var mongo = require('mongodb') ,
I have a java threads related question. To take a very simple example, lets
I see this quite a bit with online apps. Lets take, for example, the
Take the following string as an example: The quick brown fox Right now the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.