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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:30:32+00:00 2026-06-09T16:30:32+00:00

Basically, in Backbone & coffeescript, I’m pulling in tweets from the Twitter API. Fetching

  • 0

Basically, in Backbone & coffeescript, I’m pulling in tweets from the Twitter API. Fetching the JSON works, however loading the template into html does not. Pulling in the template works within the render function, however does not work within the @Tweets.fetch() function.

The line of code which seems to be failing is..

$(@.el).html(_.template($('#leTweets').html(), {tweets: tweets.models, _:_} ))

My View looks like this…

class HomeView extends Backbone.View
        constructor: ->
            super

        initialize: ->
            @Tweets= new TweetsCollection

        render: ->
            @loadResults()

        loadResults: ->
            @Tweets.fetch({
                success: (tweets) ->
                    $(@.el).html(_.template($('#leTweets').html(), {tweets: tweets.models, _:_} ))
                error: ->
                    alert('Error!')
            })

My HTML looks like this:

<script type="text/template" id="leTweets">

    <div data-role="header" data-position="fixed">
        <h1>TWEETS</h1>
    </div>

    <div data-role="content">
        <h3>Tweets</h3>
        <ul class="tweets">
        <% _.each(tweets, function (tweet) { %>

          <li><%= tweet.get('text') %></li> 

        <% }); %>
        </ul>
    </div>

</script>

And my collection looks like this:

class PropertyCollection extends Backbone.Collection

    constructor: ->
        super

    url: ->
        'http://search.twitter.com/search.json?q=' + @query + '&page=' + @page + '&callback=?'

    parse: (resp, xhr) ->
        resp.results

    page: 1,
    query: "Backbone"

Any help would be much appreciated, thanks.

  • 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-09T16:30:33+00:00Added an answer on June 9, 2026 at 4:30 pm

    I believe the issue is that the scope of “this” (@ in coffeescript) in your success handler is not your HomeView, but is “window”. Therefore ‘window.el’ does not exist.

    The simple solution is to use the ‘fat arrow’ to set the scope of the event handler to the view:

      success: (tweets) =>
          $(@.el).html(_.template($('#leTweets').html(), {tweets: tweets.models, _:_} ))
    

    This jsFiddle shows a working example: http://jsfiddle.net/edwardmsmith/PwMSP/6/

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

Sidebar

Related Questions

Basically what I need is to do something like this App.CommentView = Backbone.View.extend({ className:
Basically from C++ FAQ I learned that: A virtual function allows derived classes to
Basically, I'm trying to do something like this: Person = Backbone.Model.extend({ validate: { ...
Basically from a database I am getting data that is formatted like this nameofproject101
I've got a drag and drop UI basically working with jquery ui and backbone.js.
New to using Backbone and have a very simple application. Basically there are Clients
I'm planning on writing a spine/backbone.js style web application which basically just transfers a
Hi all I am creating my first Backbone.js app. It is basically a collection
Basically if I want to transform a name from stephen smith to Stephen Smith
I keep reading about the Backbone.js zombie (or memory leak) problem. Basically you have

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.