Skip to main content

Search and Top Navigation

#5994 closed enhancement (notabug)

Opened August 26, 2010 06:15PM UTC

Closed October 22, 2010 04:56PM UTC

Last modified November 14, 2014 01:43PM UTC

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

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

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".

Attachments (0)
Change History (6)

Changed August 26, 2010 06:23PM UTC by rdworth comment:1

component: ui.selectable[meta] ui.docs

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.

Changed August 26, 2010 06:26PM UTC by rdworth comment:2

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.

Changed October 22, 2010 04:56PM UTC by scottgonzalez comment:3

resolution: → invalid
status: newclosed

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:4

milestone: TBD

Milestone TBD deleted

Changed November 13, 2014 07:21PM UTC by Lary666 comment:5

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.

Changed November 14, 2014 01:43PM UTC by tj.vantoll comment:6

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" );
        this._super();
    }
});

Example: http://jsfiddle.net/tj_vantoll/bejfhsfm/