Skip to content

How do I grab the checked value on init? #223

@cmcguff-myob

Description

@cmcguff-myob

I have some code on changing the checkbox that toggles some UI on/off, that piece is working fine per this code

$('input[name="leave_type[validate_balance]"]').change(function() {
	$('#threshold_options').toggle($(this).prop('checked'));
});

If I try and grab the value on init, it is always false, no matter what's been saved, how do I get the state of the checkbox on first load? Everything else works perfectly.

$('input[name="leave_type[validate_balance]"]').init(function() {
    // Always false
    alert($('input[name="leave_type[validate_balance]"]').prop('checked'));
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions