I am using ASP.NET MVC and jQuery.
I have this code in my js file. It should hide and show certain divs when a user clicks on a radio button. I would also like to fire this on the page load using the trigger method. My problem seems to be that when the event is trigger my default values from the model haven't been loaded into the control and both checkboxes are false. My code would seem to be correct, but the trigger is just firing too soon. Is there a way to tell the jQuery trigger not to fire until my model data has been loaded into the controls?
$(function() { $('table#ScheduleTable
input.DailyFrequency,
input.WeeklyFrequency').click(function()
{
if ($(this).attr('checked') == true & $(this).val() == "Daily") {
$('.dailyOption').children().show();
$('.weeklyOption').children().hide();
};
if ($(this).attr('checked') == true & $(this).val() == "Weekly") {
$('.dailyOption').children().hide();
$('.weeklyOption').children().show();
} });
$('table#ScheduleTable
input.DailyFrequency,
input.WeeklyFrequency').trigger('click');
});