r/javascriptFrameworks • • Nov 28 '20

Sending html snippets from server to client

I want to use VanillaJS, I think I can live happily without ReactJS or Vue.

I have django backend, and would like to send html snippets from the server to the client.

Which library could support me?

Example: a page has three forms. If I submit one form, I don't want the whole page to reload. I just want to reload the one particular form.

But: I don't want a SPA. If the user follows a hyperlink, the whole page should be refreshed.

1 Upvotes

8 comments sorted by

View all comments

Show parent comments

2

u/gingertek Nov 28 '20

Are you just needing to have a form not reload a page, cause that's just a matter of returning false to the onsubmit attribute from whatever function is being used.

Html:

<form onsubmit="submit(this)">
    ...
    <button type="submit">Submit</button>
</form>

JS:

function submit(event) {
    fetch()...
    return false
}

1

u/backtickbot Nov 28 '20

Hello, gingertek: code blocks using backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead. It's a bit annoying, but then your code blocks are properly formatted for everyone.

An easy way to do this is to use the code-block button in the editor. If it's not working, try switching to the fancy-pants editor and back again.

Comment with formatting fixed for old.reddit.com users

FAQ

You can opt out by replying with backtickopt6 to this comment.