0

I tried to implement the solution described here but it doesn't work.These are the steps to reproduce the problem:

  • Program shows first tab selected
  • User clicks on the second tab
  • Javascript code selects first tab with

    tabViewVar.select(0)
    

where tabViewVar is defined in

 <p:tabView id="tab1" widgetVar="tabViewVar">

The result is that the first tab is selected, however the objects of the second tab are still shown (not hidden).

An ideas?

Community
  • 1
  • 1
ps0604
  • 1,227
  • 23
  • 133
  • 330
  • Your question is missing a lot of detail. At what point are you calling `select`? What version of primefaces are you running? – kolossus Jun 30 '14 at 20:20
  • My application has a div that contains the TabView. The div is hidden, and the user clicks on a button to display it. When the div and its contained TabView are displayed, the program needs to show the first tab in the TabView, so it performs `tabView.select(0)`. If it doesn't do the select, when the TabView is shown after the div is hidden, it would show the last selected tab. I'm using PrimeFaces version 3.5 – ps0604 Jul 01 '14 at 00:42
  • I just tested with PF 4.0 and have the same problem. – ps0604 Jul 01 '14 at 01:06
  • `select` only **SELECTS** tabs, it doesn't deselect them. You need to unselect them: `PF('tabViewVar').unselect(1); PF('tabViewVar').select(0);` – rion18 Jul 01 '14 at 01:58
  • @rion18 Thanks for your input. when I do `PF('tabViewVar').unselect(1);` I get a javascript error `Uncaught TypeError: undefined is not a function`. Tested with PF 5.0. – ps0604 Jul 01 '14 at 14:22
  • I'm sorry I confused accordionPanel and tabView, it seems two answers somehow got mixed up. However, `widgetVar.select(index)` should work. Testing again on the showcase website, it seems the problem comes from putting the tabView inside a div. Is there another container that is appropriate for the objective you want? – rion18 Jul 01 '14 at 22:30

0 Answers0