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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:11:50+00:00 2026-06-07T17:11:50+00:00

Given a page that uses Backbone.js to have a Collection tied to a View

  • 0

Given a page that uses Backbone.js to have a Collection tied to a View (RowsView, creates a <ul>) which creates sub Views (RowView, creates <li>) for each Model in the collection, I’ve got an issue setting up inline editing for those models in the collection.

I created an edit() method on the RowView view that replaces the li contents with a text box, and if the user presses tab while in that text box, I’d like to trigger the edit() method of the next View in the list.

I can get the model of the next model in the collection:

// within a RowView 'keydown' event handler
var myIndex = this.model.collection.indexOf(this.model);
var nextModel = this.model.collection.at(myIndex+1);

But the question is, how to find the View that is attached to that Model. The parent RowsView View doesn’t keep a reference to all the children Views; it’s render() method is just:

this.$el.html(''); // Clear
this.model.each(function (model) {
    this.$el.append(new RowView({ model:model} ).render().el);
}, this);

Do I need to rewrite it to keep a separate array of pointers to all the RowViews it has under it? Or is there a clever way to find the View that’s got a known Model attached to it?

Here’s a jsFiddle of the whole problem: http://jsfiddle.net/midnightlightning/G4NeJ/

  • 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-07T17:11:52+00:00Added an answer on June 7, 2026 at 5:11 pm

    It is not elegant to store a reference to the View in your model, however you could link a View with a Model with events, do this:

    // within a RowView 'keydown' event handler
    var myIndex = this.model.collection.indexOf(this.model);
    var nextModel = this.model.collection.at(myIndex+1);
    nextModel.trigger('prepareEdit');
    

    In RowView listen to the event prepareEdit and in that listener call edit(), something like this:

    this.model.on('prepareEdit', this.edit);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short question: I'm trying to make that in a given page (uses tabs) back
Given remote page: http://example.com/paged_list.aspx which uses a Javascript function call to display several pages
i want to have an iframe, which displays the page given as parameter in
I have a page that uses Ryan Bates nested_form plugin . The plugin is
I have a page that uses jQuery's $.post() method to get some html and
I have an ASP.net page which uses a master page. The master page has
I have an ASP.NET web application which uses EF4. I have a page with
I have a page that uses the JQuery Listnav plugin ( http://www.ihwy.com/labs/jquery-listnav-plugin.aspx ). The
I have a web browser control which has navigated to a given page and
Given an HTML page I would like to get all the 'x' files that

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.