Can't retrieve value of hidden input field in table with Jquery. Only in IE9 compatibility modus
I'm having some trouble when I try to parse a value within an jquery ajax call (1.4.4 and 1.6.2) in my asp.net mvc website. The value is in an input field within the first td of a table. When hitting a button in that same td a jquery gets triggered sending the id (a GUID) to the server.
$.ajax({
url: '/VMSW.FIS.WebUI/BetalingsAanvragen/BetalingsAanvraag/OndertekenBetalingsAanvraag',
type: 'POST',
dataType: "json",
data: {
betalingsAanvraagId: $('.datatable tbody tr:nth-child(' + options.selectedRow + ') #betalingsaanvraagid').val()
},
success: options.success,
error: function(msg){$('.error').show();}
});
Now, this code works fine in chrome and ie9. But when ie9 compatibility modus is switched on, the id (betalingsAanvraagId) suddenly returns 'undefined'!
Anyone had this problem before? Is there a solution available? Thanks in advance.
This is the body of the table:
<tbody>
@Code
Dim ix = 0
For Each betalingsAanvraag In Model.BetalingsAanvragen
End Code
<tr>
<td align="center">
<input id="betalingsaanvraagid" type="hidden" value="@betalingsAanvraag.Id.ToString()" />
<input name="1tosign" class="hideabl开发者_如何转开发e button 1stOndertekening" type="button" style="display:none;" value="Ondertekenen" visible="@betalingsAanvraag.IsNogNietOndertekend().ToString().ToLower()" />
<input name="2tosign" class="hideable button 2ndOndertekening" type="button" style="display:none;" value="2de ondertekening" visible="@betalingsAanvraag.IsGedeeltelijkOndertekend().ToString().ToLower()" />
<input name="teverzenden" class="hideable teverzenden" type="checkbox" value="@betalingsAanvraag.Id.ToString()" style="display:none;" visible="@betalingsAanvraag.IsVolledigOndertekend().ToString().ToLower()"/>
</td>
<td align="right">@betalingsAanvraag.Identificatie
</td>
<td align="right">@betalingsAanvraag.FactuurNummer
</td>
<td align="center">@betalingsAanvraag.VervalDatum.ToString("dd/MM/yyyy")
</td>
<td>@betalingsAanvraag.BegunstigdeNaam
</td>
<td>@betalingsAanvraag.MededelingSchermWaarde
</td>
<td>@betalingsAanvraag.Type
</td>
<td class="hidden">@Html.ActionLink("Details", "Detail", "BetalingsAanvraag", New With {.betalingsAanvraagId = betalingsAanvraag.Id}, Nothing)</td>
</tr>
@Code
ix = ix + 1
Next
End Code
</tbody>
You shouldn't have multiple elements with the same ID. Try using a class as the selector for the input instead and see if that works.
You can't have multiple controls with the same id. Use a class for selection or alternatively generate a unique id per row or use a selector that gets the first hidden field per row.
精彩评论