Primefaces Wizard自定义后退/后退按钮标签

时间:2020-02-17 10:33:53

标签: button primefaces label wizard

我对Primefaces向导的后退/后退按钮标签有疑问。可以像以下示例一样自定义导航按钮标签:

  • 步骤0处的按钮标签->显示按钮标签文本“下一个1”
  • 步骤1的按钮标签->显示按钮标签文本“ Next 2”和按钮后退标签“ Back 1”
  • 第2步的按钮标签->显示按钮标签文本“ Next 3”和按钮后退标签“ Back 2”
  • ...

最好的问候, 多路复用器

1 个答案:

答案 0 :(得分:2)

是的,该组件具有nextLabel和backLabel两个属性。

https://primefaces.github.io/primefaces/7_0/#/components/wizard?id=attributes

nextLabel   null    String  Label of next navigation button.
backLabel   null    String  Label of back navigation button.

然后做..

<p:wizard widgetVar="wgtWizard" nextLabel="Next #{component.step}" backLabel="Back #{component.step}">

但是由于#component.step并非在每个步骤上都经过评估,因此您必须使用JQuery JS代码来执行此操作,如下所示:

var wizard = PF('wgtWizard');
var stepIndex = wizard.getStepIndex(wizard.currentStep);
wizard.nextNav.find('.ui-button-text').text('Next ' + stepIndex);
wizard.backNav.find('.ui-button-text').text('Back ' + (stepIndex-1));

只需在向导“ onback”和“ onnext” JS方法上执行该JS代码。

相关问题