I’m looking to make something a bit like Google Docs where multiple people are able to edit a body of text concurrently.
I figured the way to do this would be to make my template just contain the text, have a helper for the template which gets the data from the database, and to fire an event on
input which just grabs the text and puts it in the database.
The issue is that this setup is causing the text to be duplicated every time my template renders. It’s like when it’s rendering, it completely ignores the fact that text is already present and it just sticks in the text.
I have a minimal reproduction which uses Session instead of a database to demonstrate this over here on StackOverflow (nobody seemed to be offering useful help there, so I figured I’d ask here: http://stackoverflow.com/q/29292054/901641 )
Currently, for a workaround (which I posted as an answer on that question), on every input event I clear out the current text so that when the template updates, it just puts the next text into the newly cleared field. This looks like an ugly hack.
I feel like what is happening is either:
- There’s a bug in the templating system (Blaze? Spacebars? I’m mixed up on what the different components of Meteor are…)
- There’s a shortcoming in the templating system (it doesn’t seem to have any hooks where I can insert my own code after it updates content.)
- I’m abusing the templating system somehow or completely going about this wrong.
I’d love to be pointed in the right direction. I’ve only been using Meteor for a week so at this stage it’s difficult to tell if the bug is in my code or if the bug is with Meteor… if someone more experienced could confirm it’s a bug, or a shortcoming, or else tell me what I’m doing wrong, that would be extremely helpful.