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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:36:05+00:00 2026-06-18T10:36:05+00:00

In my json data, i am getting projectName and assignedTo values(it accrues in all

  • 0

In my json data, i am getting projectName and assignedTo values(it accrues in all data),

example data:

  [ {projectName:'project1',assignedTo:'some1'},{projectName:'project2',assignedTo:'some2'}]

my template is: (including my confused stuff)

<script id="listTemplate" type="text/template">
    <a href="#"><%= projectName === projectName ? projectName : taskStatus%></a>//not works how can i mange?
</script>

In my view, i am converting the model "toJSON()", but i am getting the project name alone in the 2 links what i am use.

my request, Is it possible to use a single template to print two different values? – as a first time i need to print project name, later taskStatus with some condition, if so any suggestion please

  • 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-18T10:36:06+00:00Added an answer on June 18, 2026 at 10:36 am

    The reason why it is constantly printing project name is because, in the template, you have…

    <a href="#"><%= projectName === projectName ? projectName : taskStatus%></a>
    

    projectName would always equal to projectName. What you’ll want to do in this case is, in your Backbone.View, when you serialize the Model to be consumed by the template, you can do this…

    Backbone.View.extend({
        events: {
            // An example on how to change the display
            'click button.change-display': 'onChangeDisplayClicked'   
        },
        template: _.template(...),
    
        // Controls whether project name should be shown or not.
        showProjectName: true,
    
        onChangeDisplayClicked: function() {
            // Flip the switch
            this.showProjectName = !this.showProjectName;
    
            // Re-render the View
            this.render();
        },
    
        serialize: function() {
            // Grab the data from model
            var data = this.model.toJSON();
    
            // Pass this data to the template to control what to be displayed.
            data.showProjectName = this.showProjectName;
            return data;
        },
    
        render: function() {
            this.$el.html(this.template(this.serialize()));
        }
    });
    

    … and in your template, you would…

    <script id="listTemplate" type="text/template">
        <a href="#"><%= showProjectName ? projectName : taskStatu s%></a>
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Current requirement is on button click I am getting a json data through ajax
I'm having a little dilemma with an iphone project. I'm getting some JSON data
I m getting Time data in this format in an JSON Object. created_time: 2012-04-01T15:02:52+0000
I am iterating through a JSON object and I am getting the data and
I am populating the list view with data I am getting from a JSON
I am getting JSON string from website. I have data which looks like this
I am trying to display data that I am getting from server through json.
I'm try to getting JSON data but getting Error. Unexpected character encountered while parsing
i'm getting json data from the facebook-graph-api about: my relationship with my friends my
The JSON data I'm getting back from an API call has a character in

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.