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/

Recommended Answers

All 5 Replies

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); 
    }});
});
commented: very fast and fixed my dodgy code +3

Thanks for replying but sorry I don't understand where I forgot to put them?

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.