Skip to main content

Search and Top Navigation

#3803 closed feature (patcheswelcome)

Opened January 12, 2009 07:35PM UTC

Closed October 11, 2012 09:10PM UTC

Last modified October 11, 2012 09:15PM UTC

Feature request: cloning widgets

Reported by: d.wachss Owned by:
Priority: minor Milestone:
Component: ui.widget Version: 1.6rc4
Keywords: Cc:
Blocked by: Blocking:

Per this thread, clone() does not clone the widgets associated with an element. One way to do this is with a custom event:

$.fn.cloneTheWidgets = function (){
  return this.clone() // don't clone events
      var handlers = $.data(this,'events')[ 'cloneTheWidgets'];
      if (handlers) for (var handler in handlers)
        // manually trigger the clone event handlers

and in the widget init function:

init: function(){
  var self = this;
  self.element.bind('cloneTheWidgets', function() {
  ...the rest of your init

or override the native clone() to do this with some appropriate argument.

Attachments (0)
Change History (8)

Changed May 07, 2009 11:34AM UTC by jzaefferer comment:1


Changed May 04, 2010 08:02AM UTC by nxtwrld comment:2

i would suggest this behavior for 'clone':

clone(true) - automatically reinitialize the widget in the cloned DOM

clone() - cleanup the widget in the cloned DOM

Changed July 30, 2010 10:20AM UTC by jzaefferer comment:3

Do we actually want to support cloning widgets? Still seems like a rather niche usecase.

Changed July 30, 2010 11:06AM UTC by nxtwrld comment:4

Now it seems pretty inconsistent, as clone will result in cloning all the helper elements created by the widget, so you end up with a code, where widget does not work, but you can not reinitialize it again, as the original DOM has been cloned already in modified state.

Changed July 30, 2010 01:48PM UTC by scottgonzalez comment:5

component: ui.coreui.widget
milestone: 1.nextTBD

Replying to [comment:3 joern.zaefferer]:

Do we actually want to support cloning widgets? Still seems like a rather niche usecase.

We haven't made a decision, and likely won't make a decision for a while. Until we do, we're leaving the ticket open. If anyone has ideas for how to make this actually work, we'd be interested in hearing them. Unfortunately this is probably way too widget-specific to be generalized.

Changed February 27, 2012 04:25PM UTC by jzaefferer comment:6

status: newopen

Changed October 11, 2012 09:10PM UTC by scottgonzalez comment:7

resolution: → patcheswelcome
status: openclosed

If anyone has an idea for how to accomplish this, please discuss it with the team. But for now it seems like there would need to be too much widget-specific code to handle a uncommon case.

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

milestone: TBD

Milestone TBD deleted