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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:31:41+00:00 2026-06-04T17:31:41+00:00

I tried to follow http://ricostacruz.com/backbone-patterns/#inline_templates to avoid http://ricostacruz.com/backbone-patterns/#abuse however I have a typical view

  • 0

I tried to follow http://ricostacruz.com/backbone-patterns/#inline_templates to avoid http://ricostacruz.com/backbone-patterns/#abuse however I have a typical view like this:

// in app.js
App.MyView = Backbone.View.extend({
    className: "ui-widget-content",
    template: _.template($("#myTemplate").html()),
    render: function() 
    {
        this.$el.html(this.template(this.model.toJSON()));
    }

Then I just include app.js like this

<script src="./js/jquery-1.7.2.min.js"></script>
<script src="./js/jquery-ui-1.8.20.custom.min.js"></script>
<script src="./js/underscore.js"></script>
<script src="./js/backbone.js"></script>
<script src="./js/app.js"></script>

Browser complains that the $("#myTemplate") line in App.MyView.template is null (because document is not ready?). What shall I do?

  • 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-04T17:31:43+00:00Added an answer on June 4, 2026 at 5:31 pm

    my quick fix for this was to compile the template on view initialisation..

    App.MyView = Backbone.View.extend({
        className: "ui-widget-content",
        template: '#myTemplate',
        initialize: function(){
            this.template = _.template($(this.template).html());
        },
        render: function(){
            this.$el.html(this.template(this.model.toJSON()));
        }
    

    then everything else still works the same and you can put your render method in a base class..

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

Sidebar

Related Questions

I have tried to follow the instructions here http://docs.oracle.com/cd/B31017_01/web.1013/b28221/cmp30cfg001.htm Along with using generic model.
I tried to follow this instruction: http://wiki.phonegap.com/w/page/16494774/Getting-started-with-Android-PhoneGap-in-Eclipse I can run the example but when
I am trying to follow the setup on http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-in-emacs/ I have steps 1 -
Today I tried to follow the basic Twitter tutorial on : --> http://www.noupe.com/ajax/create-a-simple-twitter-app.html But
I tried to follow the instruction describe here: http://docs.oracle.com/javafx/2.0/webview/jfxpub-webview.htm to display a web page
I have started using Simple-form and Bootstrap and I have tried to follow this
I am new to play framework. tried to follow the tutorial http://www.playframework.org/documentation/1.2.4/guide2 when i
I try to follow http://edn.embarcadero.com/article/28604 for restarting Interbase. Here is some code: program IBRestart;
I tried to follow the UsingTheJRubyDebugger instructions on the jruby wiki. (kenai.com/projects/jruby/pages/UsingTheJRubyDebugger). I got
so I added all the jars from jMock 2.5.1 While attempting to follow http://www.ibm.com/developerworks/opensource/library/os-eclipse-rmock/index.html

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.