1

I am a little bit confused with Jquery .selectable. What I need to do, is to make an area that contains checkboxes to be selectable (I'm ok up to here) and then check which of the selected checkboxes are already checked (so I can uncheck them), of check them if they are not.

$("#calContainer").selectable({
    filter: 'checkbox',
    selected: function(event, ui) {
        // need code for:
        // for every checkbox in selected area thats is checked, uncheck
        // for every checkbox in selected area thats is not checked, check
    }
});

Any help is appreciated. Thanks.

mspir
  • 1,664
  • 2
  • 21
  • 34

2 Answers2

6

I would suggest wrapping your checkboxes in labels

Here's a working demo

http://jsfiddle.net/skeR4/1/

charlietfl
  • 170,828
  • 13
  • 121
  • 150
  • @gdoron drag mouse down side of checkboxes , will highlight the labels..then he wants checkboxes to flip checked property – charlietfl Mar 13 '12 at 22:40
1

I never heard of selectable plugin, but to get the checked checkboxes:

$('input[type="checkbox"]:checked')
gdoron
  • 147,333
  • 58
  • 291
  • 367
  • @Spiros. Couldn't see there `selected` option. What're you trying to do exactly, put it in the filter? – gdoron Mar 13 '12 at 21:51
  • If you go to the events tab (below the example): $( ".selector" ).selectable({ selected: function(event, ui) { ... } }); – mspir Mar 13 '12 at 21:54
  • @Spiros. Can you please create a [JSFiddle](http://jsfiddle.net/). **It is really hard to understand what is the problem you're facing.** – gdoron Mar 13 '12 at 21:59
  • @gdoron.. had troubles too, figured it out, didn't think would work but turned into interesting UI – charlietfl Mar 13 '12 at 22:36
  • Thanks. I was going to send you this link - http://jsfiddle.net/spairus/7CGpW/20/ - explaining what I need, but @charlietfl already got the answer. +1 for trying :) – mspir Mar 13 '12 at 22:55