Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect only one selectable with jQueryUI
    primarykey
    data
    text
    <p>I have a serialized selectable, and I want a function to make it only select one list item at a time. I believe I have the right code, but it's not working. Anyone know why?</p> <p>Here is my javascript:</p> <pre><code>$(function() { $( "#selectable" ).selectable({ stop: function() { var result = $( "#select-result" ).empty(); $( ".ui-selected", this ).each(function() { var index = $( "#selectable li" ).index( this ); result.append( " #" + ( index + 1 ) ); }); } }); }); $("#selectable").selectable({ selected: function(event, ui) { $(ui.selected).siblings().removeClass("ui-selected"); } }); </code></pre> <p>My selectable from the html is below. Perhaps there is a problem due to the elements nested in the <code>&lt;li&gt;</code> tags?</p> <pre><code>&lt;ul id="selectable"&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuGoogleCache2.png", alt="Google Cache" class="button" id="Google Cache" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuBingCache2.png", alt="Bing Cache" class="button" id="Bing Cache" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuYahooCache2.png", alt="Yahoo Cache" class="button" id="Yahoo Cache" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuWaybackMachine2.png", alt="WayBack Machine" class="button" id="WayBack Machine" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuCoralCDN2.png", alt="CoralCDN" class="button" id="CoralCDN" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuGigablast2.png", alt="Gigablast" class="button" id="Gigablast" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;img src="images/CacheMenuWebCite2.png", alt="Webcite" class="button" id="Webcite" height ="34px" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I appreciate your time and your help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload