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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:47:37+00:00 2026-06-08T23:47:37+00:00

I have a server side class: TopicsListModel with properties as follows: public class TopicsListModel

  • 0

I have a server side class:TopicsListModel
with properties as follows:

public class TopicsListModel
{
    public TopicsListModel()
    {
        ChildTopics = new HashSet<TopicsListModel>();
    }

    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection<TopicsListModel> ChildTopics { get; set; }
}

There is a function which returns a List,

public JsonResult SearchTopic(String topic)
    {
        var topics = LandingManager.SearchTopics(topic);
        //return Json(topics);
        return new JsonResult { Data = topic, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }

I need to add this to the Backbone model and collection. I am a newbie to Backbone and I am struggling as you can guess. Any help would be greatly appreciated.

I want to build a model which will store data like:

{    name: "Model1",    id: 1,    submodels: [{ name: "Submodel1", id: 2 }, { name: "Submodel1", id: 2 }] } 

I am unable to do so, I am having trouble setting up the basic collection like that, the ASP.NET MVC code part which returns the data I have shared. Sharing whatever I have done in the Backbone:

TestBB = function () {
if (!window.console) window.console = { log: function () { } };

var treeModel = Backbone.Model.extend({});
var treeSubModel = Backbone.Model.extend({});
var treeCollection = Backbone.Collection.extend({
    model: treeSubModel,
    initialize: function () {
        console.log('Collection Initialized');
    }
});
var treeView = Backbone.View.extend({
    el: $('#tree-view'),
    initialize: function () {
        //            this.collection.bind("render", this.render, this);
        //            this.collection.bind("addAll", this.addAll, this);
        //            this.collection.bind("addOne", this.addOne, this);
        _.bindAll(this);
    },
    render: function () {
        console.log("render");
        console.log(this.collection.length);
        $(this.el).html(this.template());
        this.addAll();
        var template = _.template($("#template").html(), {});
        this.el.html(template);
    },
    addAll: function () {
        console.log("addAll");
        this.collection.each(this.addOne);
    },
    addOne: function (model) {
        console.log("addOne");
        view = new treeView({ model: model });
        $("ul", this.el).append(view.render());
    },
    events: { "click #btnFind": "doFind" },
    doFind: function (event) { alert('event fired'); }
});

return {
    TreeView: treeView
};} (Backbone);

Please suggest.

  • 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-08T23:47:40+00:00Added an answer on June 8, 2026 at 11:47 pm

    Solved
    I figured out the approach and defined the model and populated it!

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

Sidebar

Related Questions

I have a server side object. public class OptionRelation { public intOptionId { get;
I have a class at server-side like this: public class Address { public Address(string
In server side I have following class public class EditorContext { public Module Module
I have created a class for fetching server-side data in my iOS-App, based on
I have class in server side and I want use method of this class
Does anyone have a class which I can run on the server side which
I have a server side class which I make available on the client side
Server side extjs form validation using zend framework I have extended Zend_Form class to
Is it possible to have a generic server-side query like the following? public IQueryable<TContact>
I have a server side code to process uploaded binary files: class UploadHandler(webapp.RequestHandler): def

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.