TAGS :Viewed: 8 - Published at: a few seconds ago
[ How to return sender from Jquery autocomplete ]
I use Jquery Autocomplete in my mvc3 application. I have a lot of textbox, and i try to do it smart :) I need to return autocomplete field property to controler. like that:
<script type="text/javascript" >
$(document).ready(function () {
$(".AutoC[id]").autocomplete('@Url.Action("Liczba_wejsc", "Home")', { minChars: 1, selectFirst: true, extraParams: { "ID": $(this).attr('id')} });
});
</script>
<div class="editor-field">
@Html.ValidationMessageFor(m => m.some_prop)
<br/>@Html.TextBoxFor(m => m.some_prop, new {
id = "some_id", @class = "AutoC" })
</div>
But allways i get null.
Answer 1
Ok i get it :
</script>
<script type="text/javascript" >
$(document).ready(function () {
$(".AutoC").each(function() {
var id = $(this).attr("id");
$(this).autocomplete('@Url.Action("Liczba_wejsc", "Home")', { minChars: 1, selectFirst: true, extraParams: { "ID": id} });
});
});
</script>