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

The Archive Base Latest Questions

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

In my Backbone view, i am setting tagname, classname, temp value.. all are works

  • 0

In my Backbone view, i am setting tagname, classname, temp value.. all are works fine apart from classname..

how do i set the classname.. or what is the mistake on my code..

define(["singleton","listCollection","listModel"],function(singleton,collection,listModel){
    singleton.view = Backbone.View.extend({
        tagName     :'article',
        className   :'indBoard',
        projectName : true,
        template0   : _.template($('#listTemplate').html()),
        template1   : _.template($('#boardTemplate').html()),
        initialize  :function(options){
            this.template = this['template'+options.tempNo];
            this.tagName = options.tagName;
                    //i am changing to 'li' works
            this.className = options.cName; 
                    //changing to new class name not working
            console.log(options.cName);//consoles new class name properly
                  this.projectName = options.subTempNo == 0 ?true:false;                 
                   //condition as well works..
        },
        render:function(){
            var temp = this.template;
            this.$el.html(temp(this.model.toJSON()));
            return this;
        }
    });
    return singleton.view;
});
  • 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-18T16:22:06+00:00Added an answer on June 18, 2026 at 4:22 pm

    If you set options.className when you create your view instance instead of options.cName, you don’t need to try to set it in initialize like that (same for tagName).

    Try something like this instead:

    var view = new singleton.view({className: 'someClass'});

    className is one of the special options that Backbone looks for during the view creation.

    From Backbone source:

    // List of view options to be merged as properties.
    var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events'];
    

    Actually, I think the reason tagName is working for you is because it is being merged in by Backbone, and not because you are setting it in initialize.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a backbone view like so window.InputView = Backbone.View.extend({ tagName:'input', className:'', attributes:{}, initialize:function(){
I got following example Backbone.View : var View = Backbone.View.extend({ tagName: "div", className: "advertisement",
var foo = Backbone.View.extend({ tagName: 'div', className: 'unselected', events: { 'click div' : 'select'
I know Backbone.js's View object has parameters like id , tagName , className .
here is my scenario of backbone view var TreeNode = Backbone.View.extend({ tagName : span,
I have a backbone view that has render() called from its parent view returning
I have the following class that extends Backbone.View, I want all my backbone views
The problem is that all Object attributes apart from 'name' call the error 'id/url/whatever
Inside Backbone.View instances one can set an events hash of callbacks: events: { 'click
So I have a Backbone view in which I declare it's className. I'm trying

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.