0

I'm developing a choice widget that should be able to show groups of checkboxes as selectable items.

Some of them would be readonly, no problem with those.

Issue1: Some though, must be uncheckable by the user, before submitting the form. But JQ Select2 only shows the inputs inside, not allowing me to click on them.

This is my code so far. Select2 with inner checkboxes Demo

Here's the initialization, start reading from the bottom.

$(document).ready(function() {
    var $choice = colonizacion.integrateSelect2();
    colonizacion.addHiddenValueUpdater($choice);
});

The HTML, brings the checkbox options in a container div's data-options attribute, which gets parsed and rendered as selectable optoins.

Issue2: another issue is that if the checkbox group contains more than one checkbox, the jqselect2 doesn't re-dimension itself, shwing just the 1st one.

The Alternative I can think of, without knowing the internals of JQSelect2 is to trigger the generation of the checkboxes group DOM elements outside the JQSelect2 as regular inputs, returning no markup, so it'd be empty. But that's nasty.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
juanmf
  • 2,002
  • 2
  • 26
  • 28
  • I think **Issue1** can be solved by [this code](http://jsfiddle.net/ant_Ti/s2dqh/12/), referenced [here](http://stackoverflow.com/questions/15636302/attach-click-event-to-element-in-select2-result) still reading.. Still have Issue2 without a clue – juanmf Jun 03 '14 at 14:19
  • I correct myself, last comment point to a solutions for the dropDown list, I need a similar solution for selected item. They say there that the (not shown) hack for this broke the Select2. – juanmf Jun 03 '14 at 14:50
  • Ok, I moved on and changed the requirement, as unchecking the checkbox in the result List was much easier that doing so in the Selected Item, after Result List closed.. [here's the code](http://jsfiddle.net/juanmf/LUsMb/3114/) see **Line 79** `target.prop('checked', ! target.prop('checked'));`. **Issue2** still remains unsolved. Researching on it. – juanmf Jun 04 '14 at 20:16

0 Answers0