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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:30:40+00:00 2026-06-03T22:30:40+00:00

I’m using backbone.js, underscore.js and jQuery. I took the following sample code from http://jsfiddle.net/thomas/C9wew/6/

  • 0

I’m using backbone.js, underscore.js and jQuery. I took the following sample code from http://jsfiddle.net/thomas/C9wew/6/:

<!DOCTYPE html>
<html>
    <head>
        <title>backbone.js</title>
    </head>
    <body>
        <div id="search_container">
            Container
        </div>

        <script src="/js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/underscore-min.js" type="text/javascript" charset="utf-8"></script>
        <script src="/js/backbone-min.js" type="text/javascript" charset="utf-8"></script>

        <script type="text/template" id="search_template">
            <label>Search</label>
            <input type="text" id="search_input" />
            <input type="button" id="search_button" value="Search" />
        </script>

        <script type='text/javascript'>
            //<![CDATA[
            $(window).load(function() {

                SearchView = Backbone.View.extend({
                    initialize : function() {
                        this.render();
                    },
                    render : function() {
                        // Compile the template using underscore
                        var template = _.template($("#search_template").html(), {});
                        // Load the compiled HTML into the Backbone "el"
                        //this.el.html(template);
                        this.el.innerHTML = template;
                    },
                    events : {
                        "click input[type=button]" : "doSearch"
                    },
                    doSearch : function(event) {
                        // Button clicked, you can access the element that was clicked with event.currentTarget
                        alert("Search for " + $("#search_input").val());
                    }
                });

                var search_view = new SearchView({
                    el : $("#search_container")
                });

            });
            //]]>

        </script>
    </body>
</html>

I’m expecting “el” to be a jQuery wrapped element, because is selected through a jQuery selector $(“#search_container”), however is not because it doesn’t have a function like html().

If I put a breakpoint at the line “el : $(“#search_container”)”, the “el” element has the function html(), which is the normal behavior. When the render function is called, the “el” element does not have anymore the html() function..any ideea?

  • 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-03T22:30:42+00:00Added an answer on June 3, 2026 at 10:30 pm

    The example you linked is based on an old version of backbone (0.3.3). Your sample probably uses the latest version (0.9.2) where this.el is a DOM element and this.$el is a cached jQuery|Zepto element associated with this.el.

    This means that if you want to use the html method, use this.$el.html(template). Check this Fiddle http://jsfiddle.net/gFcRR/1/ for an updated example.

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.