2

I've been working on an one page app, and noticed that my dropdowns stays open sometimes when they suppose to be hidden. I investigated why that happens and find out that if parent element is hidden, hiding element with jQuery UI using extended hide functions is worthless.

This fiddle example which shows what I mean, just try to click Hide & Show buttons, and then click Show parent1 and try to hide element there. You'll notice that status indicator gets updated instantly but once you back to parent2 you'll see the element is still visible.

I found that using jQuery hide without arguments or only with miliseconds passed, it does work correctly and stops working once I update it with jQuery UI arguments, so I assume it is jQuery UI not jQuery itself problem.

So my question is why jQuery UI is working in this way, is that the way it suppose to work or it is a bug?

j08691
  • 204,283
  • 31
  • 260
  • 272
Giedrius
  • 1,590
  • 3
  • 16
  • 27

2 Answers2

0

I think its the way its supposed to work. In this case when you go back to parent2 on the line $('#parent2').show();, it by default shows all child elements too.. That is the show() is iterated on all elements inside parent2. Though this seems cumbersome, there is a way around it in this JSFiddle which is a modified version of yours.

Ajo Koshy
  • 1,205
  • 2
  • 21
  • 33
  • well it would make sense it to work in this way, but there is plenty of old bug reports about jQuery itself been working this way, which was fixed and now only jQuery UI works in this way, I think it is a bug, because there suppose to be same behaviour with functions which shares the same name. Your example in JSFiddle is quite complex for such a simple thing, I think simply calling a callback for `hide` function is much simpler way to workaround this issue. I already filled up bug report. – Giedrius Feb 25 '13 at 11:12
  • @giedrius i didn't use callback for `hide` because you had specified it with a delay. My method made it look like it worked all right.. There are alternate methods too working to this effect. And my method felt simple since i just added a flag to the effect to do the work. Cheers!! – Ajo Koshy Feb 25 '13 at 11:27
0

It was a bug in jQuery UI, which got fixed in 1.10.2.

Here is a link to bug report ticket http://bugs.jqueryui.com/ticket/9120

Giedrius
  • 1,590
  • 3
  • 16
  • 27