Reputation: 3283
I'm using NodeJS, Express, MongoDB, Mongoose and jade for the web app. I am wondering how I pass data from jade to mongodb. The data that I want to pass are texts inside certain divs that are appended to the web page as users create them.
Example.
<div class="c1">
<div class="c2">
Object 1
</div>
<div class="c2">
Object 2
</div
</div>
I want to pass the text inside class c2 divs to mongodb. As of right now, I'm using
a(href="/save/", value="Publish", class="button") Publish
But the problem is that after if I press this link, it will get redirected to localhost:3000/save/ but all the populated divs will not get transported, as they shouldn't because I'm not passing anything. I'm thinking I should have some sort of onclick function for the link. But then I don't know where to go from there.
Upvotes: 0
Views: 300
Reputation: 38400
How do your users edit the texts inside the div
s? Are you using contentEditable
? While that's a nice feature, it requires some work and knowledge of web development to implement that properly.
I'd suggest the simplest and "proper" way to do it, would be use textarea
s instead of the div
s, and just submit them as a form:
<form action="/save/" method="post" class="c1">
<textarea name="c2" class="c2">
Object 1
</textarea>
<textarea name="c2" class="c2">
Object 2
</textarea>
<input type="submit" value="Publish">
</form>
Upvotes: 1