Alex Rivera | Logout

how to find selected elements with Jquery UI selectable

Asked 2009-08-20T00:11:17.067
16

I am looking for info on the event and ui objects the jQuery selectable events: "selecting", and "start" take as parameters. I cannot find this in the documentation and looping through the properties is no help.

$('#content_td_account').selectable({
    filter: 'li:not(".non_draggable")',
    selecting: function(event, ui) { 
    }
});

Specifically I want to find what elements are being selected and check them to see if their parent elements are the same or not. I assumed this would be in the ui object some where.

Edit
Report

2 Answers

0

this will solve your problem:

    <script type="text/javascript">
    $(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));
                });
            }
        });
    });
    </script>


<div class="demo">

<p id="feedback">
You've selected: <span id="select-result">none</span>.
</p>

<ol id="selectable">
    <li class="ui-widget-content">Item 1</li>
    <li class="ui-widget-content">Item 2</li>
    <li class="ui-widget-content">Item 3</li>
    <li class="ui-widget-content">Item 4</li>
    <li class="ui-widget-content">Item 5</li>
    <li class="ui-widget-content">Item 6</li>
</ol>

check out http://jqueryui.com/demos/selectable/#serialize for more info

answered 2010-05-10T06:50:38.577
-1

the ui argument in that event is the reference to the elemenent, if it was the selected event ui.selected event will be the elemennt, if it was unselect unselected.ui.....etc

answered 2011-12-19T09:13:27.120

Your Answer