I am working on something that requires me to have li's in different parents. I am using jquery Selectable to get the function of selecting the li's and also the ability to drag the mouse to select multiple li's.
This is working great apart from the fact that I need someway of including all of the li's under both parents when they are selected rather than acting as two seperate containers.
So in this example, when you drag over the numbers it will select all in the first block but not move onto the second block starting at number 13.
I need this to include all of the numbers somehow without having to move all of my li's into the same parent container.
(Sorry if I'm not explaining this well, I am struggling to explain what I mean. It will make more sense looking at the example: https://jsfiddle.net/susannalarsen/enq7bx22/1/
HTML:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<body>
<ol id="selectable">
<li class="ui-state-default">1</li>
<li class="ui-state-default">2</li>
<li class="ui-state-default">3</li>
<li class="ui-state-default">4</li>
<li class="ui-state-default">5</li>
<li class="ui-state-default">6</li>
<li class="ui-state-default">7</li>
<li class="ui-state-default">8</li>
<li class="ui-state-default">9</li>
<li class="ui-state-default">10</li>
<li class="ui-state-default">11</li>
<li class="ui-state-default">12</li>
</ol>
<div style="clear:both;"></div>
<ol id="test">
<li class="ui-state-default">1</li>
<li class="ui-state-default">2</li>
<li class="ui-state-default">3</li>
<li class="ui-state-default">4</li>
<li class="ui-state-default">5</li>
<li class="ui-state-default">6</li>
<li class="ui-state-default">7</li>
<li class="ui-state-default">8</li>
<li class="ui-state-default">9</li>
<li class="ui-state-default">10</li>
<li class="ui-state-default">11</li>
<li class="ui-state-default">12</li>
</ol>
CSS:
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 450px; }
#selectable li { margin: 3px; padding: 1px; float: left; width: 100px; height: 80px; font-size: 4em; text-align: center; }
#test .ui-selecting { background: #FECA40; }
#test .ui-selected { background: #F39814; color: white; }
#test { list-style-type: none; margin: 30px 0px 0px 0px; padding: 0; width: 450px; border:1px solid black; }
#test li { margin: 3px; padding: 1px; float: left; width: 100px; height: 80px; font-size: 4em; text-align: center; }
SCRIPT:
+$(function() {
$( "#selectable, #test" ).selectable();
});
Try adding a listener to a parent group, in this case body.