J'ai maintenant ajouté ce methid javascript:
$(document).ready(function() {
$("#ModelViewAd\\.TypeOfAd :radio").change(function() {
if (this.id.match('TypeOfAd_Sell$') != null) {
$("#ModelViewAd_BuyNowPrice").removeAttr('disabled');
$("#divBuyNowPrice").fadeIn(500, null);
$("#divReservationPrice").fadeOut(500, null);
$("#ModelViewAd_ReservationPrice").attr('disabled', 'disabled');
$("#divEndDate").fadeOut(500, null);
$("#ModelViewAd_EndDate").attr('disabled', 'disabled');
$("#divStartingPrice").fadeOut(500, null);
$("#ModelViewAd_StartingPrice").attr('disabled', 'disabled');
}
else if (this.id.match('TypeOfAd_Buy$')) {
$("#divReservationPrice").fadeOut(500, null);
$("#ModelViewAd_ReservationPrice").attr('disabled', 'disabled');
$("#divEndDate").fadeOut(500, null);
$("#ModelViewAd_EndDate").attr('disabled', 'disabled');
$("#divStartingPrice").fadeOut(500, null);
$("#ModelViewAd_StartingPrice").attr('disabled', 'disabled');
$("#divBuyNowPrice").fadeOut(500, null);
$("#ModelViewAd_BuyNowPrice").attr('disabled', 'disabled');
}
else if (this.id.match('TypeOfAd_Let$')) {
$("#ModelViewAd_BuyNowPrice").removeAttr('disabled');
$("#divBuyNowPrice").fadeIn(500, null);
$("#divReservationPrice").fadeOut(500, null);
$("#ModelViewAd_ReservationPrice").attr('disabled', 'disabled');
$("#divEndDate").fadeOut(500, null);
$("#ModelViewAd_EndDate").attr('disabled', 'disabled');
$("#divStartingPrice").fadeOut(500, null);
$("#ModelViewAd_StartingPrice").attr('disabled', 'disabled');
}
else if (this.id.match('TypeOfAd_WishRent$')) {
$("#divBuyNowPrice").fadeOut(500, null);
$("#ModelViewAd_BuyNowPrice").attr('disabled', 'disabled');
$("#divReservationPrice").fadeOut(500, null);
$("#ModelViewAd_ReservationPrice").attr('disabled', 'disabled');
$("#divEndDate").fadeOut(500, null);
$("#ModelViewAd_EndDate").attr('disabled', 'disabled');
$("#divStartingPrice").fadeOut(500, null);
$("#ModelViewAd_StartingPrice").attr('disabled', 'disabled');
}
else if (this.id.match('TypeOfAd_Swap$')) {
$("#divBuyNowPrice").fadeOut(500, null);
$("#ModelViewAd_BuyNowPrice").attr('disabled', 'disabled');
$("#divReservationPrice").fadeOut(500, null);
$("#ModelViewAd_ReservationPrice").attr('disabled', 'disabled');
$("#divEndDate").fadeOut(500, null);
$("#ModelViewAd_EndDate").attr('disabled', 'disabled');
$("#divStartingPrice").fadeOut(500, null);
$("#ModelViewAd_StartingPrice").attr('disabled', 'disabled');
}
else if (this.id.match('TypeOfAd_Auktion$')) {
$("#ModelViewAd_BuyNowPrice").removeAttr('disabled');
$("#divBuyNowPrice").fadeIn(500, null);
$("#ModelViewAd_ReservationPrice").removeAttr('disabled');
$("#divReservationPrice").fadeIn(500, null);
$("#ModelViewAd_EndDate").removeAttr('disabled');
$("#divEndDate").fadeIn(500, null);
$("#ModelViewAd_StartingPrice").removeAttr('disabled');
$("#divStartingPrice").fadeIn(500, null);
}
})
});
RadioButton est mis sur la validation correcly échoué du serveur au client, mais le javascript est pas runned jusqu'à ce qu'un RadioButton est modifié manuellement?
Déplacez tout ce qui est actuellement dans votre gestionnaire de changement, '$ (" # ModelViewAd \\. TypeOfAd: radio "). Changez (function() {...})', en une nouvelle fonction. Appelez ensuite cette fonction depuis le gestionnaire de changement AND dans la fonction jQuery ready. – Ryan