mardi 26 mai 2015

Determine if all jQueryUI checkboxes(buttons) are unchecked

I have a series of jQueryUI checkboxes rendered by html like the following...

<input class="asset-tile-select-input" id="asset-tile-select-input-84" type="checkbox"
name="asset-tile-select">
<label for="asset-tile-select-input-84"></label>

And I make them go with...

$("input[id*='asset-tile-select-input']").button(
{
    text: false
});

Then, whenever (I thought) the box is un/checked, I use the following to determine if I should show/hide a related element...

$("input[id*='asset-tile-select-input']").change(
function()
{
    if( $("input[id*='asset-tile-select-input']:checked") )
    {
        alert("asdf");   
        if( $("#box-asset-icon-container").is(":visible") == false )
        {
            $("#box-asset-icon-container").show(300);
        }
    }
    else
    {
        if( $("#box-asset-icon-container").is(":visible") == true )
        {
             $("#box-asset-icon-container").hide(300);
        }
    }
});

Only, the alert fires whether I check or uncheck the box. WHY? It works one way, in that it will .show() the related element if something's checked. How do i set this up so it knows whether all like checkboxes are not checked and in turn hides the related #box-asset-icon-container element?




Aucun commentaire:

Enregistrer un commentaire