JSF渲染后重新加载Anythingslider [英] Reload Anythingslider after JSF render
问题描述
渲染列表中的div后,我试图重新加载Anythingslider.
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>
注意:预览div位于slider1列表附近
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?
我不希望重新加载整个页面,因为下拉菜单不是我要渲染的唯一组件
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.
推荐答案
看来问题在于noConflict()
模式在函数内部被多次调用,将其移到外部:
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>
这篇关于JSF渲染后重新加载Anythingslider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!