Made a plugin to allow for dynamic generation is rails.
jQuery.fn.toggleServiceItems = function(settings){
var config = {
'check_box_class' : 'ach',
'toggled' : 'sec_codes'
};
if (settings) $.extend(config, settings);
$('input.'+config['check_box_class']).click(function() {
if ($('input.'+config['check_box_class']).is(":checked")) {
$('#'+config['toggled']).show('fast');
} else {
$('#'+config['toggled']).hide('fast');
}
});
};
//use
$("input.ach").toggleServiceItems({
'check_box_class' : 'ach',
'toggled' : 'sec_codes'
});
On Jan 14, 1:45 pm, joshmckin <[email protected]> wrote:
> ahhh even better,
>
> thanks Sime
>
> On Jan 14, 12:36 pm, Šime Vidas <[email protected]> wrote:
>
> > $("input.ach").click(function() {
> > if ($("input.ach").is(":checked")) {
> > $('#sec_codes').show('fast');
> > } else {
> > $('#sec_codes').hide('fast');
> > }
>
> > });