mongodb - Updating presentation layer when the mongo document changes -


I have a list of dogs in a table with the underlying dog model and the collection of dogs. When I change the name of a dog's document in the Mongo collection, I want to show the name of the new dog without updating the table list item and refreshing the page.

I thought this was going to happen when you can get table row items to update when you change model ?? Start the: function () {} default: {_id: null, DogName: "",}}}); Window.DogCollection = Backbone.Collection.extend ({Model: dog, url: "/ dogs / user /",}); Window.DogListView = Backbone.View.extend ({initialize: function () {this.listenTo (this.model, 'change', this.render); this.render ();}, render: function () {var dogs = This.model.models; $ (this.el) .html (for this.template ()); (var i = 0; i & lt; dogs.length; i ++) {this. $ ('# DogsTable tbody '.append ({Model: dog [i], no: i + 1} .render () .l);} this. $ (' # Dogs'). DataTable ({"BitWood": False, "IDisplayLength": 50}); it back;}}); Window.DogListItemView = Backbone.View.extend ({tagname: "tr", start: function (option) {this.listenTo (this.model, 'change', this.render); this.model.bind ("change Model.bind ("delete", this.code, this), not it. Options = no; this.render ();}, render: function () {$ (this .el) .html (this.template ({no: this.no, id: this.model.get ("_ id"), dogName: this.model.get ("dogName"),})); ;}, Event: {"click .delete": "deleteDog",}});

And finally in the spine controller I use this to load the scene:

  var dogList = new DogCollection (); DogList.url = "/ dogs / user /" + this.user.get ("_ id"); DogList.fetch ({Success: Work () {$ ('# content'). Html (new doglist view ({model: dogList}).);}});  

What are you doing now:

  • Set up a URL for this collection
  • Get archive and get success
  • Li>
  • Display the data received in these views

This is perfectly fine and in these views (maybe, your code has not been tested) archive.

However, there is no way in your application to know that after receiving the data something changes in your Mongo database. If you want to achieve this functionality, you can do one of the following examples;

  • Make a collection archive (and thus refresh) at a time.
  • Notify your application that some servers have changed using webcots. If you want to do this, you can use a library such as

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -