The last post was mangled; I wanted to say you could use a custom
event:
$.fn.cloneTheWidgets = function (){
  return this.clone() // don't clone events
   .each(function(){
      var handlers = $.data(this,'events')['cloneTheWidgets'];
      if (handlers) for (var handler in handlers) handlers
[handler].apply(this); // manually trigger the clone event handlers
    }
};

and in the widget init function:

init: function(){
  var self = this;
  self.element.bind('cloneTheWidgets', function() {$(this)
[self.widgetName](self.options)});
  ...the rest of your init
}

Though I haven't tested this.

Danny

On Jan 9, 5:01 pm, jayg <[email protected]> wrote:
> Scott, sorry for the delayed response, had to come up with a stripped
> down test page and find somewhere to put it.  I have used for my
> example, I used the superbox 
> onhttp://youngisrael-stl.org/wordpress/2008/08/22/extending-jquery-ui-w...
> The example page can be found 
> here:http://sarahhealydesign.com/widget_test.html
>
> What I am trying to do seems like it should be simple, and perhaps I
> am missing something obvious.  Basically all I do is attach a click to
> the button, and do:
> $('#experiment1')
>            .clone(true)
>            .appendTo('body')
>            .attr('id','experiment2');
>
> I attached an alert to the superbox, so whenever you click it, it
> tells you what it thinks is its id with this.element.get(0).id
>
> You will see in the example that it always returns experiment1 for the
> id.  Any help is much appeciated!
>
> -j
>
> On Jan 8, 11:20 am, Scott González <[email protected]> wrote:
>
> > Can you provide a demo page showing your problem?
>
> > On Jan 7, 10:20 pm, jayg <[email protected]> wrote:
>
> > > I have a custom widget built on jquery UI that I am running into an
> > > odd issue with.  Everything works as I want on initial use, but when I
> > > do a clone(true) on the widget and append it to another element, the
> > > cloned version does not seem to have a proper handle on where it lives
> > > in the dom - it returns the old id upon calling this.element.get
> > > (0).id.  Do I need to do something, maybe call some method, to update
> > > this information w/in the widget, or is this only ever set upon
> > > initial creation?  I did try calling $('#myItem').myWidget('init'),
> > > but no dice.  Any thoughts?  Something obvious I am missing?

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

Reply via email to