jQuery: The Write Less, Do More JavaScript Library

Selectable and single select (or no mouseDrag).

View: New views
5 Messages — Rating Filter:   Alert me  

Selectable and single select (or no mouseDrag).

by Jack-142 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Is there a way to disable the drag select in a jQuery.UI.Selectable
list? I only want single selections, and want to turn off the ability
to select multiple items.

Thanks
Jack

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@...
To unsubscribe from this group, send email to jquery-ui+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selectable and single select (or no mouseDrag).

by Richard D. Worth-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sounds far simpler than anything the selectable plugin is designed for. How about:

$("#myList > *").click(function() {
  $(this).toggleClass("selected").siblings().removeClass("selected");
});

- Richard

On Tue, Mar 10, 2009 at 2:10 PM, Jack <jackambrose@...> wrote:

Is there a way to disable the drag select in a jQuery.UI.Selectable
list? I only want single selections, and want to turn off the ability
to select multiple items.

Thanks
Jack




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@...
To unsubscribe from this group, send email to jquery-ui+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selectable and single select (or no mouseDrag).

by SexyBeast () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

your code fragment does not seem to work for me. Could you please instruct me where exactly I have to put it in my document?

That's how I tried it:
<script type="text/javascript">
        $(document).ready(function() {
                $("#selectable").selectable({
                        //
                        click: function(){
                                $(this).toggleClass("selected").siblings().removeClass("selected");
                        },
                       
                        stop: function(){
                                var result = $("#select-result").empty();
                                $(".ui-selected", this).each(function(){
                                        var index = $("#selectable li").index(this);
                                        result.append(" #" + (index + 1));
                                });
                        }
                        //
                });
        });
</script>


Thank you very much!
Regards, Tom




Richard D. Worth-2 wrote:
Sounds far simpler than anything the selectable plugin is designed for. How
about:

$("#myList > *").click(function() {
  $(this).toggleClass("selected").siblings().removeClass("selected");
});

- Richard

On Tue, Mar 10, 2009 at 2:10 PM, Jack <jackambrose@gmail.com> wrote:

>
> Is there a way to disable the drag select in a jQuery.UI.Selectable
> list? I only want single selections, and want to turn off the ability
> to select multiple items.
>
> Thanks
> Jack
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to jquery-ui+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---
------BEGIN GEEK CODE BLOCK------
Version: 3.1
GIT/E d- s+:-- a C++ UL++ P+ W+ w
M-- PS t+ tv-- b+++ G e* h* r% y?
-------END GEEK CODE BLOCK-------

Re: Selectable and single select (or no mouseDrag).

by Richard D. Worth-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My code fragment was not meant to be used with selectables, but in place of it:

<script type="text/javascript">
$(document).ready(function() {
  $("#selectable").children().click(function() {
    $(this).toggleClass("selected").siblings().removeClass("selected");
  });
});
</script>

- Richard

On Wed, Apr 22, 2009 at 4:18 AM, SexyBeast <johndavies@...> wrote:


Hello,

your code fragment does not seem to work for me. Could you please instruct
me where exactly I have to put it in my document?

That's how I tried it:
<script type="text/javascript">
       $(document).ready(function() {
               $("#selectable").selectable({
                       //
                       click: function(){
                               $(this).toggleClass("selected").siblings().removeClass("selected");
                       },

                       stop: function(){
                               var result = $("#select-result").empty();
                               $(".ui-selected", this).each(function(){
                                       var index = $("#selectable li").index(this);
                                       result.append(" #" + (index + 1));
                               });
                       }
                       //
               });
       });
</script>

Thank you very much!
Regards, Tom





Richard D. Worth-2 wrote:
>
> Sounds far simpler than anything the selectable plugin is designed for.
> How
> about:
>
> $("#myList > *").click(function() {
>   $(this).toggleClass("selected").siblings().removeClass("selected");
> });
>
> - Richard
>
> On Tue, Mar 10, 2009 at 2:10 PM, Jack <jackambrose@...> wrote:
>
>>
>> Is there a way to disable the drag select in a jQuery.UI.Selectable
>> list? I only want single selections, and want to turn off the ability
>> to select multiple items.
>>
>> Thanks
>> Jack
>>
>> >
>>
>
> >
>
>

--
View this message in context: http://www.nabble.com/Selectable-and-single-select-%28or-no-mouseDrag%29.-tp22445910s27240p23156093.html
Sent from the jQuery UI Discussion mailing list archive at Nabble.com.





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@...
To unsubscribe from this group, send email to jquery-ui+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Selectable and single select (or no mouseDrag).

by SexyBeast :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello!

Not quite, but you were close:

Your line:
    $(this).toggleClass("selected").siblings().removeClass("selected");
is programmatically correct, but refers to the wrong class. It must be 'ui-selected' instead of  'selected'. ( took me ages to find out..  )

So
   $(this).toggleClass("ui-selected").siblings().removeClass("ui-selected");
works for me.


Obviously this has been the problem when I tried it before. (I am a noob to jquery , so it still is a bit confusing)

Anyway: thank you very very much for your help!

regards,
Tom


Richard D. Worth-2 wrote:
My code fragment was not meant to be used with selectables, but in place of
it:

<script type="text/javascript">
$(document).ready(function() {
  $("#selectable").children().click(function() {
    $(this).toggleClass("selected").siblings().removeClass("selected");
  });
});
</script>

- Richard

On Wed, Apr 22, 2009 at 4:18 AM, SexyBeast <johndavies@freenet.de> wrote:

>
>
> Hello,
>
> your code fragment does not seem to work for me. Could you please instruct
> me where exactly I have to put it in my document?
>
> That's how I tried it:
> <script type="text/javascript">
>        $(document).ready(function() {
>                $("#selectable").selectable({
>                        //
>                        click: function(){
>
>  $(this).toggleClass("selected").siblings().removeClass("selected");
>                        },
>
>                        stop: function(){
>                                var result = $("#select-result").empty();
>                                $(".ui-selected", this).each(function(){
>                                        var index = $("#selectable
> li").index(this);
>                                        result.append(" #" + (index + 1));
>                                });
>                        }
>                        //
>                });
>        });
> </script>
>
> Thank you very much!
> Regards, Tom
>
>
>
>
>
> Richard D. Worth-2 wrote:
> >
> > Sounds far simpler than anything the selectable plugin is designed for.
> > How
> > about:
> >
> > $("#myList > *").click(function() {
> >   $(this).toggleClass("selected").siblings().removeClass("selected");
> > });
> >
> > - Richard
> >
> > On Tue, Mar 10, 2009 at 2:10 PM, Jack <jackambrose@gmail.com> wrote:
> >
> >>
> >> Is there a way to disable the drag select in a jQuery.UI.Selectable
> >> list? I only want single selections, and want to turn off the ability
> >> to select multiple items.
> >>
> >> Thanks
> >> Jack
> >>
> >> >
> >>
> >
> > >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Selectable-and-single-select-%28or-no-mouseDrag%29.-tp22445910s27240p23156093.html
> Sent from the jQuery UI Discussion mailing list archive at Nabble.com.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery UI" group.
To post to this group, send email to jquery-ui@googlegroups.com
To unsubscribe from this group, send email to jquery-ui+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---
------BEGIN GEEK CODE BLOCK------
Version: 3.1
GIT/E d- s+:-- a C++ UL++ P+ W+ w
M-- PS t+ tv-- b+++ G e* h* r% y?
-------END GEEK CODE BLOCK-------