Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery UI selectable, links not being followed on click

Tags:

jquery-ui

Using the jQuery UI library selectable(). Links within the selectable list items are not being followed on click, only by right clicking and opening in new window or tab.

HTML

<ul class="selectable-list">
    <li>
        <p>Visit Google.</p>
        <a href="http://www.google.com">Google</a>
    </li>
    <li>
        <p>Visit Apple.</p>
        <a href="http://www.apple.com">Apple</a>
    </li>
    <li>
        <p>Visit Microsoft.</p>
        <a href="http://www.microsoft.com">Microsoft</a>
    </li>
</ul>

CSS

.selectable-list li.ui-selected, .selectable-list li.ui-selected:hover {
    background-color: #ccc;
}

JS

$(document).ready(function(){

    $(".selectable-list").selectable();

});
like image 590
jerome Avatar asked Oct 12 '09 17:10

jerome


1 Answers

The selectable() method takes an option called cancel. By default, it is ":input,option", but you can use it to make your anchors not applicable to the selectable event.

For your code:

$(document).ready(function() {
    $(".selectable-list").selectable({
        cancel: 'a'
    });
});
like image 126
Lance McNearney Avatar answered Oct 11 '22 12:10

Lance McNearney