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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:58:21+00:00 2026-05-31T22:58:21+00:00

I have been using Backbone.js to act as a middleman between WordPress (using the

  • 0

I have been using Backbone.js to act as a middleman between WordPress (using the super rad JSON API plugin) and my front end.

Each of my WordPress posts has a YouTube video ID attached to it, which is getting pulled back when I fetch the collection.

I am trying to work out the best point within the application to go out and parse the video ID to get the total video views.

This is code that is fetching the collection model:

parse: function(response) {
  return response.posts;
}

And the following code is then rendering the appropriate view.

this.getCollection().each(function(model) {
  var view = new App.Thumbnail.View({model: model});
  var item = $(view.render().el);
  this.container.append(item);
});

At some point in this process, I need the thumbnails to assign themselves the video count. This is the code I have for grabbing the YouTube view count:

function getYoutubeViewCount(videoID) {
  $.ajax({
    url: "http://gdata.youtube.com/feeds/api/videos/" + videoID + "?v=2&alt=json",
    dataType: "jsonp",
    success: function (data) { console.log(data.entry.yt$statistics.viewCount); }
  });
}

So my question is, where do you think the best place to fetch the view count is? Should I create a sub-model that fetches the count? Or do it outside of backbone.js?

Any help would be beyond appreciated!

Thanks in advance,
Charlie.

  • 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-31T22:58:23+00:00Added an answer on May 31, 2026 at 10:58 pm

    The viewCount should be an attribute on your Video model subclass. You can load both the wordpress data for the video and the youtube count in parallel before instantiating your model, or you can instantiate your model with the data from wordpress while the youtube data is being fetched and latered applied. Once you get the view count from youtube, set it on the corresponding model instance. Have your view bind to the change:viewCount event on the model and re-render itself (or at least shove the view count into the appropriate element in the DOM) once this data is loaded.

    As to WHEN you do this, probably you should start fetching the view count(s) in the background as soon as you have your basic Video model instance created and populated with its basic attributes from your wordpress data source. Or you can choose to load view counts later lazily when the video is played or scrolled into the viewport or moused over or whatever.

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

Sidebar

Related Questions

I have been using json.NET successfully in projects for some time now without any
I have been using Backbone on a new project and so far have loved
Background I have been using Backbone.js for some time and one aspect of it
I have been using the Gdocs API to upload images without conversion. In the
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using PHP and JavaScript for building my dad's website. He wants
I have been using Eclipse as an IDE for a short amount of time
I have been using Castle MonoRail for the last two years, but in a
We have been using Scrum for around 9 months and it has largely been
I have been using C# for a while now, and going back to C++

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.