Reload Anythingslider after JSF render

孤街醉人 提交于 2019-12-12 02:27:29

问题


I am trying to get my Anythingslider to be reloaded, after rendering the divs, which are in the list.

    <h:selectOneMenu id="dropdownDevice"
        value="#{skinningBean.currentDevice}" converter="SkinConverter">
        <f:selectItems value="#{skinningBean.myDevicesSI}" var="c"
            itemValue="#{c}" />
        <a4j:ajax event="change" render="preview" oncomplete="reloadSlider()" />

    </h:selectOneMenu>

Note: the preview div is around the slider1 list

<script type="text/javascript">  
function reloadSlider() {  
    var $jq = jQuery.noConflict();
    $jq(function($){
      $jq('#slider1').anythingSlider();
    }); 
}  
</script>   

But I get this error all the times (I tried more than this solution):

Error: TypeError: $jq(...).anythingSlider is not a function

After this, only the simple list elements are shown. Any ideas how I can achieve reloading the slider?

Edit: I don't want the whole page to be reloaded, because the dropdown menu isn't the only component I'm rendering from

This is how I initialize anythingslider:

<script src="../js/jquery.anythingslider.js"></script>
<link rel="stylesheet" href="../css/anythingslider.css" />

<script type="text/javascript">
var $jq = jQuery.noConflict();
$jq(function($){
  $jq('#slider1').anythingSlider();
}); 
</script>

I just copied it and wrapped it with a function, so I can call it a second time.


回答1:


It appears the problem is that the noConflict() mode is being called more than once inside the function, move it outside:

<script type="text/javascript">  
var $jq = jQuery.noConflict();
function reloadSlider() {  
    $jq(function($){
      $jq('#slider1').anythingSlider();
    }); 
}  
</script> 


来源:https://stackoverflow.com/questions/15521029/reload-anythingslider-after-jsf-render

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!