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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:39:04+00:00 2026-06-15T08:39:04+00:00

I’m working out my first backbone.js app and have run into a bit of

  • 0

I’m working out my first backbone.js app and have run into a bit of a wall. Perhaps someone can help me past this hurdle (gap in my understanding). What I want/need to do is to return the collection data to my router, so I can bind it to a Kendo UI Grid, but I’m not seeing any of the search results in my collection… I figure I must be missing something fundamental, but I’m not sure what it is.

Here is what I have so far:

    ES.Router = Backbone.Router.extend({routes: {
            '': 'search',
            'search': 'search',
            'results': 'results'
        },
        results: function() {
            var resultsData = new ES.Results();
            var boo = resultsData.fetch({
                    data: JSON.stringify({"query":"myquery"}),
                    type: 'POST',
                    contentType: 'application/json'
                    });
            console.log(boo);
        }});

    ES.Result = Backbone.Model.extend();

    ES.Results = Backbone.Collection.extend({   
        model: ES.Result,
        url: '/search/query'
        });
  • 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-15T08:39:05+00:00Added an answer on June 15, 2026 at 8:39 am

    There are a few issues here:

    1. A fetch should be a GET, not a POST, because a fetch should not save or modify anything
    2. Maybe just a personal preference, but I’d url as a function, so as to avoid trying to modify the AJAX request options manually.
    3. The fetch call will always be asynchronous, so you need to either add a success callback in the options hash, or add a listener to the collection’s reset event

    I’d write the collection like this:

    ES.Results = Backbone.Collection.extend({   
        initialize: function() {
            this.query = "test";
        },
        model: ES.Result,
        url: function() {
            return '/search/query?query=' + this.query;
        }
    });
    

    Then set the search when you create the collection:

    var resultsData = new ES.Results();
    resultsData.query = "soccer";
    

    And use success and/or the on("reset") event to handle the result:

    resultsData.on("reset", function(collection) {
        console.log(collection);
    });
    
    console.log("Fetching....");
    resultsData.fetch({
        success: function(collection, response) {
            console.log("Got data!" + collection.length);
        },
        error: function(collection, response) {
            console.log("Error: " + response.responseText);
        }
    });
    

    ​

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I am currently running into a problem where an element is coming back from
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.