meteor-editable-text-wysiwyg-bootstrap-3
meteor-editable-text-wysiwyg-bootstrap-3 copied to clipboard
How to make a insert field?
I can't manage to put up an insert field. I can use the editor fine on the posts I automatically fill in, but following the example demo I only get a button that automatically inserts an empty post in my collection, instead of opening a "form" like the demo shows. Optionally I'd like to use it in modal form (I have a modal ready but I need to know how to get input fields).
I have the following fields to insert: title - post title image - post thumbnail body - post content timestamp - post date author - user that inserted post
Timestamp and author should be added automatically with the callback, however only timestamp is being added, and as I mentioned above, the rest of the inserted post is empty.
My project is structured to have a /posts route and then a /postsDetails for each post.
Another issue I noticed, is that changes are being saved automatically on my details route when I click outside of the WYSIWYG instead of just saving on the save icon. I'd like to deactivate that.
If you can post a sample on meteorpad, I'll take a look and see if I can find what's wrong.
Essentially though, you need to initialize the widget with autoInsert=true
and make sure that the object you want to insert is the context surrounding the widget.
In the example app, the button doesn't open a form. It inserts a post into the posts collection and this is immediately displayed via the pub/sub transfer of data to the client and reactive UI. It just looks like a form because pretty much every element in the post is in-line editable. Once you can see that post (that looks like a form), it's already a document in the database and you're just making updates to the existing document from there on in.
I don't know if this is right, because I never used meteorpad with my own code but I haven't seen it render other projects the past days as well.
http://meteorpad.com/pad/dEKsSwLs7jkm5tvep/WYSIWYGposts
I can't get Meteorpad to show anything, but I can see what's happening with the code. There is nothing in your context for the the newly inserted document (context: {}
), so it's going to get no fields except the field in the widget (title
) and the timestamp that you're doing via a callback.
Take a look at the full docs and the example code.
Yeah Meteorpad is with issues for every project it seems. I'm guessing the issue here is I'm doing this in the list instead of the individual document and thus I truly am creating a vanilla document... but that's how it's gotta be... I guess I can insert the placeholder values into the new document and go from there...
That's kind of what the autoInsert=true
thing is for ... when you've got something in a list where documents are only really differentiated by one field and just want a one-liner to add a dummy item (document) into the list that the user can edit seamlessly to make it a real document behind the scenes.
Sorry ... that sentence was just one big stream of consciousness.