user3616539
user3616539

Reputation: 9

JQuery ui how to make certain elements in a selectable not selectable

I have a list of JQuery ui selectable elements called "#selectable" and there are some elements inside the selectable that I no not want to be selectable, I want them there as list dividers.

Here is an example of what the list looks like:

<ol>
    <li class='custType'>This is a divider</li>
    <li class='ui-widget-content'>This is selectable</li>
    <li class='ui-widget-content'>This is selectable</li>
    <li class='ui-widget-content'>This is selectable</li>
    <li class='custType'>This is a divider</li>
    <li class='ui-widget-content'>This is selectable</li>
    <li class='ui-widget-content'>This is selectable</li>
</ol>

The ones that have the class "custType" are dividers and I no not want them to be selectable, it just divides the list up into categories.

Upvotes: 0

Views: 340

Answers (1)

j08691
j08691

Reputation: 207861

Use the filter option to only select those items that should be selectable:

$( ".selector" ).selectable({ filter: "li" });

In your case:

$( "ol" ).selectable({ filter: "li.ui-widget-content" });

jsFiddle example

Upvotes: 4

Related Questions