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

  • Home
  • SEARCH
  • 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 7399977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:07:58+00:00 2026-05-29T04:07:58+00:00

I’m using backbone with the backbone-rails gem which does its own templating and project

  • 0

I’m using backbone with the backbone-rails gem which does its own templating and project structure.

The problem is that it puts 4 different views on one div, so what i’ve done is made another div and now the model, show,edit views are assigned to that other view, basically so i can have a list on the left side of the page and everything else in the middle.

The problem is that i can’t redirect now, so when i update or create a new ‘note’ the list view does not refresh.

List View:

  Supernote.Views.Notes ||= {}



  class Supernote.Views.Notes.IndexView extends Backbone.View

  template: JST["backbone/templates/notes/index"]



   initialize: () ->

  @options.notes.bind('reset','change', @addAll)





 addAll: () =>

 @options.notes.each(@addOne)



 addOne: (note) =>

 view = new Supernote.Views.Notes.NoteView({model : note, collection: @options.notes})

  @$("li").append(view.render().el)



 render: =>

 $(@el).html(@template(notes: @options.notes.toJSON() ))

 @addAll()



 return this

Edit View:

  Supernote.Views.Notes ||= {}



 class Supernote.Views.Notes.EditView extends Backbone.View

  template : JST["backbone/templates/notes/edit"]



 events :

  "submit #edit-note" : "update"



 update : (e) ->

  e.preventDefault()

  e.stopPropagation()



  @model.save(null,

  success : (note) =>

    @model = note

    window.location.hash = "/#{@model.id}"

   )



 render : ->

  $(@el).html(@template(@model.toJSON() ))



 this.$("form").backboneLink(@model)



 return this
  • 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-29T04:07:59+00:00Added an answer on May 29, 2026 at 4:07 am

    Events is what you need,
    when a model is added to a collection (new note)
    it raises the add event on the collection itself

    so in your collection you can catch that and do something with it.

    var myCollection = Backbone.Collection.extend({
       //... whole lot of irrelevant stuff goes here :)
    });
    
    var myCollectionListView = Backbone.View.extend({
    
      initialize: function(){
        _.bindAll(this, 'onAdd');
        this.collection.bind('add', this.onAdd);
      }
    
      onAdd: function(m){
        // either re-render the whole collection
        this.render();
    
        // or do something with the single model
        var item = $('<li>' + m.get('property') + '</li>');
        $('#listview').append(item);
      }
    
    });
    
    
    var myItems = new myCollection({});
    var listview = new myCollectionListView({ collection: myItems });
    

    then you have the ‘add note’ covered, (the exact same you could do for the reset or remove event which handle resetting the collection with a new list of models, and deleting a model from the collection )

    let’s say you update a note, this should be done with the same event system, though the change event could be used for that.
    the trick here is, your list view renders not the model elements itself, but the list view creates a modelview for every model. in that modelview (you called it NoteView) you could do the same process as above,
    and bind to it’s own model:

    initialize: function() {
      this.bind('change', this.modelChanged);
    },
    
    modelChanged: function(m){
      // do something, re-render the view, or anything else...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.