简体   繁体   English

JS Wai-aria和jQuery加载的动态内容

[英]JS wai-aria and dynamic content loaded with jQuery

I'm writing an web application which uses twitter bootstrap and aria . 我正在编写一个使用twitter bootstraparia的Web应用程序。 I have table with sort option which looks: 我有带排序选项的表,看起来: http://scr.hu/0ti4/4m3b7 . My content is dynamically loading into #content div with jQuery.html() function. 我的内容是使用jQuery.html()函数动态加载到#content div When I hit F5 everything works fine, but after I load content by jQuery to my div which contains these tables, something goes wrong. 当我按F5一切正常,但是当我通过jQuery将内容加载到包含这些表的div中后,出现了问题。 Tables loses their search options and pagination bars.. like this: 表格会丢失其搜索选项和分页栏。 http://scr.hu/0ti4/42lll .

There are few functionality which stop working too. 很少有功能会停止工作。 How should I load dynamic content into my #content div ? 如何将动态内容加载到#content div

My current code: 我当前的代码:

this.getContent = function(page){
    var self = this;
    $('#center-column').removeAttr("class");
    if (page.indexOf('&') > 0)
        $('#center-column').addClass( page.substr(0, page.indexOf('&') ) );
    else $('#center-column').addClass( page );

    $.get( $('body').attr('id')+".php?page="+page+"&mode=ajax",
        function(data){
            self.fetchData( data );
        }, "json");
}

this.fetchData = function(data){
    if (data.redirect_url != null)
        window.location = data.redirect_url;
    $("#content").html( data.html );
}

Is there any method aria has and I should call after I change content of my div dynamicly? aria有什么方法可以动态更改div的内容并调用?

after I load content by jQuery to my div which contains these tables, something goes wrong. 当我通过jQuery将内容加载到包含这些表的div中后,出现了问题。 Tables loses their search options and pagination bars 表格丢失了搜索选项和分页栏

Use .wrap to add dynamic content around the existing markup: 使用.wrap在现有标记周围添加动态内容:

$("#content").html(  $(data.html).wrap("#content")  )

Is there any method aria has and I should call after I change content of my div dynamicly? aria有什么方法可以动态更改div的内容并调用?

Use the aria-live attribute to indicate the content is dynamic, and assertive as the value. 使用aria-live属性以指示内容是动态的, assertive的价值。

$("#content").attr("aria-live", "assertive")

References 参考文献

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

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