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 9026027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:25:17+00:00 2026-06-16T06:25:17+00:00

I would like to say when question_number changes, run updateQuestionNumber . If anything EXCEPT

  • 0

I would like to say “when question_number changes, run updateQuestionNumber. If anything EXCEPT question_number (and whatever else I give a custom render function), run .render()”.

The problem with the following code is that both updateQuestionNumber AND render run.

v.QuestionBuilder = Backbone.View.extend({
    initialize: function() {
        this.model.on('change:question_number', this.updateQuestionNumber, this);
        this.model.on('change', this.render, this);
    },
    //only this function should run when question_number is changed
    updateQuestionNumber: function(){
        this.$('.question-number').text(this.model.get('question_number'));
    },
    //this should run when anything except question_number is changed
    render: function() {
        this.$el.html(this.template(this.model.toJSON()));
        this.$el.fadeIn('slow');

        /* blah blah blah */
        return this;
    }
});
  • 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-16T06:25:18+00:00Added an answer on June 16, 2026 at 6:25 am

    Here is the best solution I could think of:

    When this.render() fires I set an array non_render of properties which don’t require a full render (are taken care of by this.model.on('change:whatever', this.whateverRenderFunction, this);). Then it checks the changedAttributes. If there is anything in there that’s NOT in non_render (._difference) then it continues. Otherwise it returns.

    This seems like a super-bulky solution though (and I have to maintain the non_render list both in initialize and in render. Any improvements would be awesome…

        render: function(model, value, options){
            if(model){ //this was triggered via .change()
                var changed = _.keys(model.changedAttributes());
                var non_render = ['question_number'];
    
                //if there is anything in changed that's not part of non_render
                if(_.difference(changed, non_render).length === 0){
                    return false;
                }
            }
    
            var data = this.model.toJSON();
            _.extend(data, _.result(this.templateProperties));
    
            this.$el.html(this.template(data));
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off I would like to say that I think that my question may
Seen many other similar questions like this on this website and i would say
First I would like to say that I am new to this site, never
First off I would like to say that this is my first post and
first of all i would like to say i know its probably an easy
Let say I would like to set nested style for development and compressed for
I would like to apply successive animations (say ScaleAnimation) to an ImageView showing a
Lets say that I would like to construct a list (L2) by appending elements
Lets say I would like to calculate percents and do: double n = ...;
I would like to provide a facade class to the existing AmazonS3Client (say MyAmazonS3Client),

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.