Opened 10 years ago

Closed 10 years ago

Last modified 6 years ago

#5994 closed enhancement (notabug)

selectable("destroy") could remove "ui-selected" class

Reported by: hubquery Owned by:
Priority: minor Milestone: none
Component: [meta] Version: 1.8.4
Keywords: Cc:
Blocked by: Blocking:


When calling selectable("destroy"), should removeClass("ui-selected") be called as well as the current removeClass("ui-selectee")?

Some people might want to preserve the ui-selected items when the selectable is destroyed, though, in which case maybe just the documentation should be adjusted to say "This will return the element back to its pre-init state, leaving selected items with the ui-selected class".

Change History (6)

comment:1 Changed 10 years ago by rdworth

Component: ui.selectable[meta]

The current behavior is correct. I could see us updating the docs, but basically when we say "return the element back to its pre-init state" we mean that destroy corresponds to init, so what is done in init is un-done by destroy. As init doesn't add the ui-selected class, then destroy shouldn't remove it.

comment:2 Changed 10 years ago by rdworth

An example for comparison, I don't think anyone would expect .draggable('destroy') to return the draggable element to where it was before init, even if that's technically part of its pre-init state.

comment:3 Changed 10 years ago by Scott González

Resolution: invalid
Status: newclosed

comment:4 Changed 8 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

comment:5 Changed 6 years ago by Lary666

To be honest, it isn't obvious that the ui-selected class will remain. This is a class used by the plugin and most of the time, when you will call Destroy, you will want to clear the selection and put an end the selection process. The draggable comparison is not valid because it does not add a ui-draggable-dragged class.

comment:6 Changed 6 years ago by tj.vantoll

Milestone: none

Just as an fyi if you really need this behavior you can write an extension that does this really easily:

$.widget( "ui.selectable", $.ui.selectable, {
    _destroy: function() {
        this.selectees.removeClass( "ui-selected" );


Note: See TracTickets for help on using tickets.