What techniques do you use for emitting data from the server that will solely be used in client side scripts?
Posted
by
chuck
on Stack Overflow
See other posts from Stack Overflow
or by chuck
Published on 2010-12-29T17:18:21Z
Indexed on
2010/12/29
17:53 UTC
Read the original article
Hit count: 183
Hi all,
I never found an optimal solution for this problem so I am hoping that some of you out there have a few solutions.
Let's say I need to render out a list of checkboxes and each checkbox has a set of additional data that goes with it. This data will be used purely in the context of javascript and jquery. My usual strategy is to render this data in hidden fields that are grouped in the same container as the checkbox.
My rendered HTML will look something like this:
<div>
<input type="checkbox" />
<input type="hidden" class="genreId" />
<input type="hidden" class="titleId" />
</div>
My only problem with this is that the data in the hidden fields get posted to the server when the form is submitted. For small amounts of data, this is fine. However, I frequently work with large datasets and a large amount of data is needlessly transferred.
UPDATE: Before submitting this post, I just saw that I can add a "DISABLED" attribute to my input element to suppress the submission of data. Is this pretty much the best approach that I can take?
Thanks
© Stack Overflow or respective owner