0

Can anyone help me with jquery ui selectable please?

My html is:

<input style="" id="input_4" name="input_4" value="" />
                        <ol id="selectable">
                            <li class="ui-widget-content">Reservations </li>
                            <li class="ui-widget-content">Information and Enquiries</li>
                            <li class="ui-widget-content">Mambo Tours &amp; Events</li>
                            <li class="ui-widget-content">Press, Marketing &amp; PR</li>
                            <li class="ui-widget-content">Business Development &amp; Franchise</li>
                            <li class="ui-widget-content">Mambo TV &amp; Livestreaming</li>
                            <li class="ui-widget-content">Mambo Studio</li>
                            <li class="ui-widget-content">VIP Services</li>
                            <li class="ui-widget-content">Merchandise</li>
                            <li class="ui-widget-content">Wedding Planning</li>
                            <li class="ui-widget-content">Club Tickets</li>
                        </ol>​

and my jquery is:

$(function() {
    $("#selectable").selectable(selected: function(event, ui) { 
            var text = $(this).text();
            $("#input_4").val(text); 
      });

});​

I want whatever is selected to update the input text field which I want to hide and store the value in.

Anyone please? It's driving me insane with the lack of documentation on jquery ui selectable.

Cheers,

Kevin


http://jsfiddle.net/kevindougans/J7BQx/2/

3
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by abtraju
1

You forgot {} around your options, and this points to selectable, not the selected item.

$(function() {
    $("#selectable").selectable({selected: function(event, ui) { 
            var text = $('.ui-selected').text();
            $("#input_4").val(text); 
    }});
});

Edited by pritaeas: n/a

Votes + Comments
very fast and fixed my dodgy code
0

Mate... you just saved me about 5,000 strands of hair!!!!!!! Thank you ever so much!!!!!

0

is any possible to add jQuery ui selectable for content loaded via AJAx i.e after page load content added automatically like twitter tweet. i tried but it works only page initial page loaded content.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.