简体   繁体   English

有什么滑块不能与a4j:ajax一起使用?

[英]Anythingslider not working with a4j:ajax?

I am trying to use Anythingslider to slide between divs: 我正在尝试使用Anythingslider在div之间滑动:

    <h:panelGroup id="preview" layout="block"
        style="float: left; margin-left: 100px;">

        <ul id="slider">
            <li><ui:include src="./preview/WelcomePreview.xhtml" /></li>
            <li><ui:include src="./preview/CardPreview.xhtml" /></li>
        </ul>

    </h:panelGroup>

But as soon if I include a table into the site, it won't work anymore. 但是,一旦我在网站中加入表格,该表格将无法使用。 Please note that I am NOT including the table to the div which i include to the slider! 请注意,我没有将表格包括在div中,而将其包括在滑块中! It is outside of the list. 它不在列表中。 Maybe it isn't the table which causes an error. 可能不是导致错误的表格。

This is the html I try to include: 这是我尝试包含的html:

<rich:collapsiblePanel header="Title" switchType="client"
    expanded="false">

    <table style="table-layout: fixed;">
        <h:form>

            <tr>
                <td class="firstTD"><h:outputLabel value="Title: " /></td>
                <td><h:inputText id="title"
                        value="#{skinningBean.currentSkin.title}">
                        <a4j:ajax event="keyup" render="preview" />
                    </h:inputText></td>
            </tr>
        </h:form>
    </table>
</rich:collapsiblePanel>

EDIT 编辑

I already figured out, that this line of code produces the error: 我已经知道,这一行代码会产生错误:

    <a4j:ajax event="keyup" render="titlePreview" />

Is there any way to make it work properly when using ajax? 使用ajax时,有什么方法可以使其正常工作吗?

EDIT 编辑

The first thing I did to avoid not finding the right javascript function was adding the jQuery noConflict tag: 为避免找不到正确的javascript函数,我要做的第一件事是添加jQuery noConflict标签:

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

Now my only problem is, that as soon as something is rendered on the page, the javascript isn't working anymore. 现在,我唯一的问题是,一旦页面上呈现了某些内容,JavaScript就不再起作用。 I guess this is because the javascript is just loaded at page initialize. 我猜这是因为javascript仅在页面初始化时加载。 And the rendering doesn't load the full page beacuse of performance? 渲染是否由于性能而无法加载整个页面?

The noConflict() mode is not being set properly. noConflict()模式未正确设置。 It should be done outside of the document ready function, like this: 应该在文档准备功能之外完成,如下所示:

var $jq = jQuery.noConflict();
$jq(function($){
  $('#slider1').anythingSlider();
});

I've never used a4j before, but from a quick look in the docs, I think the oncomplete attribute needs to be used to re-initialize the slider. 我以前从未使用过a4j,但是从文档中的快速浏览来看,我认为需要使用oncomplete属性来重新初始化滑块。 Try something like this: 尝试这样的事情:

<a4j:ajax event="keyup" render="preview" oncomplete="initSlider()" />

Then change the javascript to this: 然后将javascript更改为此:

var $jq = jQuery.noConflict();

function initSlider() {
  $jq(function($){
    $('#slider1').anythingSlider();
  });
}

As I said, I'm clueless about using a4j, but this looks like it might work. 如我所说,我对使用a4j一无所知,但这似乎可行。

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

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