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

  • Home
  • SEARCH
  • 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 5939227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:47:49+00:00 2026-05-22T15:47:49+00:00

Here i want to make a view in backbone.js // The DOM element for

  • 0

Here i want to make a view in backbone.js

// The DOM element for a User item...
    var UserView = Backbone.View.extend({
        //... is a list tag.
        tagName:  "li",
         // Cache the template function for a single item.
        template: _.template($('#tmpl_occupant').html()),

        // a one-to-one correspondence between a **User** and a **UserView** in this
        // app, we set a direct reference on the model for convenience.
        initialize: function() {

            _.bindAll(this, 'render', 'close');
            this.model.bind('change', this.render);
            this.model.view = this;
        },
        // Re-render the contents of the User item.
        render: function() {
            $(this.el).html(this.template(this.model.toJSON()));
            return this;
        }
    });

This view code i put in the user.js and when index.html load it is called and it gives error

str is null
http://myserver/rahul/js/underscore-1.1.3.js
Line 675

i think it is due to because error not come when i remove this line

  template: _.template($('#tmpl_occupant').html()),


<script type="text/html" id="tmpl_occupant">
    <%=user.username%> is in <%=gib.name%> (<%=channel%>)
    </script>

i think it is because index.html is not completely loaded while this line is executed .so it don’t fine tmpl_occupant , what can i do to solve this problem.

  • 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-05-22T15:47:54+00:00Added an answer on May 22, 2026 at 3:47 pm

    Done it by passing directly string instead of jquery reference.
    or

    http://documentcloud.github.com/underscore/#template
    and better solution is to compile the template and pass the template to the instance of view.

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

Sidebar

Related Questions

I want to model messages between users, here is the requirement: User has received
Here is the idea: When the user wants to see /controller/action, then I want
i want to make message view show all other messages that led up to
I've managed to find the Regex to get almost the result I want here
Here's what I'd like to do: I want to create a library project that
I want to implement the solution using the pre-processor described here: Reuse define statement
Here's a simple (hopefully) L10N question: Do all locales want this format: Sunday, Nov
Here's the scenario: I have a set of buttons that I want to bind
Ok here's what I'm trying to do I want to write a class that
Here's my requirement: 1. I want my installable to have a custom license agreement

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.