简体   繁体   English

JSF页面中的$ .noConflict()冲突

[英]$.noConflict() conflict in JSF page

I have a Primefaces chart which I want to use with AJAX tab: 我有一个Primefaces图表,我想与AJAX选项卡一起使用:

<h:head>

</h:head>
<h:body>
    <div id="test" style="width:850px; height:800px; position:absolute;  background-color:transparent; ">

        <h:form>
            <h:panelGroup layout="block">
                <h:selectOneListbox size="0" id="selectedMenu" value="#{dashboardController.selectedMenu}">
                    <f:selectItem itemLabel="first" itemValue="0" />
                    <f:selectItem itemLabel="second" itemValue="1" />
                    <f:selectItem itemLabel="third" itemValue="2" />

                    <f:ajax event="change" execute="@this" render="loadMenu" />
                </h:selectOneListbox>
            </h:panelGroup>

            <h:panelGroup layout="block" id="loadMenu">
                <h:panelGroup rendered="#{dashboardController.selectedMenu=='0'}">
                    MENU 0
                </h:panelGroup>

                <h:panelGroup rendered="#{dashboardController.selectedMenu=='1'}">
                    MENU 1
                </h:panelGroup>

                <h:panelGroup rendered="#{dashboardController.selectedMenu=='2'}">
                    MENU 2
                </h:panelGroup>
            </h:panelGroup> 
        </h:form>    
    </div> 
</h:body>


@ManagedBean
@ViewScoped
public class DashboardController implements Serializable{

private String selectedMenu;

@PostConstruct
public void init() {
    if (selectedMenu == null || selectedMenu.trim().isEmpty()) {
        this.selectedMenu = "0";
    }
}

public String getSelectedMenu() {
    return selectedMenu;
}

public void setSelectedMenu(String selectedMenu) {
    this.selectedMenu = selectedMenu;
} 
}

I use this code for the charts: 我在图表中使用此代码:

<script type="text/javascript">
   $.noConflict();
   // Code that uses other library's $ can follow here.
</script>
    ..........

<p:lineChart id="logins" value="#{StatisticsController.weekActivity}" legendPosition="ne"  
                                 title="Weekly Logins" seriesColors="4D94FF, 1975FF, 005CE6, 0047B2" minY="0" maxY="200"/>

When I remove 当我删除

<script type="text/javascript">
    $.noConflict();
    // Code that uses other library's $ can follow here.
</script>

When AJAX tabs are working. 当AJAX选项卡正常工作时。 It seems that the $.noConflict(); 看来$.noConflict(); code is in conflict. 代码冲突。 How I can solve this problem? 我怎么能解决这个问题?

因此,从primefaces库中删除jquery include,然后让它使用你已经包含的jQuery。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM