I'm using MVC3 with razor view. I'm giving the user a list of <li>
s to select from:
<ol id="selectable">
@foreach (var ebat in Model.AvailableSizes)
{
<li class="ui-widget-content">@ebat.Item1 x @ebat.Item2</li>
}
</ol>
where Model.AvailableSizes is a List<Tuple<int,int>>
. When the user selects one of them, I want to be able to find from jQuery which Tuple<int,int>
the user wants to use.
By the way I am using jqueryui Selectable with these list.
I guess I can find the selected element with $(".ui-selected:first")
, but how can I get the associated Model data, namely @ebat.Item1
and @ebat.Item2
, so that I can send them to the server as parameters?
I'm quite suspicious about my initial approach here, I mean it shouldn't be this hard. So if you could show me the better way to use model, html and jquery together in this kind of situations, it would be fantastic. Thanks.