1

I'm currently passing in an object into my ECT html file (same as EJS just for coffeescript) which has a form. This object contains a business name, business id and visit id and I only display the business name inside my ECT file.

I'm trying to pass the business object into the body with my post request that contains all the form details. I've tried the whole data-* (http://html5doctor.com/html5-custom-data-attributes/) but that isn't working.

This is what my form looks like right now

<form id="form" action="/answer" method="post" data-biz="<%= @business%>">
# Inputs here

However, my request body only contains the values for my inputs and nothing with the business object. Is there any way to pass my business object back into my post request for /answer?

Thanks!

1 Answer 1

1

You can JSON.stringify the object and pass it through a hidden input:

<form id="form" action="/answer" method="post">
  <input name="name" value="<%= @business.name %>"/>
  <input name="business" type="hidden" value="<%= JSON.stringify(@business) %>"/>
</form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.