It may be the same issue, but datepicker doesn't use the $.ui.widget code and I haven't analysed it in detail, so I can't tell you. The problem of clone(true) copying event handlers that refer to the original data-storing object is likely a problem. You might have to look at the datepicker code to determine how it binds event handlers to figure out what's going wrong.
On Jan 12, 12:55 pm, Jason <[email protected]> wrote: > Could this be the same issue that I'm running in to with my clone() > problem? > I posted about it here but never got any > response:http://groups.google.com/group/jquery-ui/browse_thread/thread/e27b2c3... > I am cloning without the event handlers and then reinitializing the > datepicker but the widget still isn't triggering. Does changing the id > not work like this? > Thanks, > Jason > > On Jan 12, 8:59 am, Scott González <[email protected]> wrote: > > > Jay, thanks for creating the test case, and thanks Danny for beating > > me to a response :-) > > > Danny's response is fully correct and in fact while I was looking at > > your example, I was thinking about how we would support this natively > > and came to pretty much the same conclusion as Danny. If one of you > > wants to create a feature request in Trac > > (http://ui.jquery.com/bugs/newticket > > ), we'll try to get this in for 1.7. > > > On Jan 10, 10:44 pm, Danny <[email protected]> wrote: > > > > 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 -~----------~----~----~----~------~----~------~--~---
