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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:24:10+00:00 2026-06-06T21:24:10+00:00

Supposed I have two different Objects I am trying to load in an eventual

  • 0

Supposed I have two different Objects I am trying to load in an eventual BackBone view.

My Rails Controller

def index
  @visuals = Visual.all
  @words   = Word.all

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: [@visuals, @words] }
  end
end

On place I can add it is here :

My Rails View:

#visuals

:javascript
  $(function() {
    window.router = new AiProject.Routers.VisualsRouter({test_visuals: #{ @visuals.to_json.html_safe } });
    // AiProject.words = new Words(#{@words.to_json});
    //  ^^ Would this be the best place to insantiate my controller code's instance variable?
    Backbone.history.start();
  });

But other people say to put it in your template. Which is strange because I think my BackBone’s framework puts it in the router:

Coffee BB Router

show: (id) ->
  visual = @visuals.get(id)

  @view = new AiProject.Views.Visuals.ShowView(model: visual)
  $("#visuals").html(@view.render().el)

So if that was the case, maybe I should try and insantiate @words there?

  • 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-06T21:24:11+00:00Added an answer on June 6, 2026 at 9:24 pm

    edit – this was not talking about bootstrapping.

    You need to be calling the index action somewhere, probably directly via jQuery.ajax as it doesn’t correspond directly to a single backbone model or collection.

    In the success handler of your ajax call, you can assign the returned data to whatever you want to assign it to in backbone.

    I would probably have models for single visuals and words, then collections of each as well (in raw javascript as i’m out of practice with coffeescript at the moment):

    MyApp.Models.Visual = Backbone.Model.extend();
    MyApp.Models.Word = Backbone.Model.extend();
    
    MyApp.Collections.Visuals = Backbone.Collection.extend({
      model: MyApp.Models.Visual
    });
    
    MyApp.Collections.Words = Backbone.Collection.extend({
      model: MyApp.Models.Word
    });
    
    var visuals, words;
    
    $.ajax({
      url: <path to index action>
      dataType: 'json',
      success: function (data) {
        visuals = new MyApp.Collections.Visuals(data[0]);
        words = new MyApp.Collections.Words(data[1]);
      }
    });
    

    at this point, you have your visuals and words collections, and can do whatever you need to do with them.

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

Sidebar

Related Questions

Supposed I have two classes like this: public class Parent { public string Id
Supposed that I have two arrays: Dim RoomName() As String = {(RoomA), (RoomB), (RoomC),
I have two functions that are supposed to encrypt and decrypt a string but
I have a script (python) supposed to build up two paths - one in
I have an array of objects with different properties and I need to filter
I have two different java projects (I'll call them project 1 and Project 2
I'm creating my own UserControl and I have two different DataTemplates under the UserControl.Resources
I am stubbing two different objects. Here are the interfaces: public IInterface1 { IEnumerable<Foo>
I have two different models that need saving; a TextFile object and a static
I am trying to sort an arrayList in two different ways, one by the

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.