如何使用jquery重新渲染

如何使用jquery重新渲染,jquery,jquery-mobile,Jquery,Jquery Mobile,我想知道如何使用jquery重新呈现dom元素。 我想按ID捕获一个表,并使用jquery重新呈现该表 此表是动态输入的。由于我是在加载html文件后添加表的,所以头部的Js文件不会响应我在加载html页面后添加的表。这是通过编辑器完成的 因此,我需要使用jquery重新呈现表。我使用Jquery和Jquery mobile作为我的框架 *对不起,我好像走错了路。我实际上想做的是使用jquery mobile重新呈现dom元素 function insertTemplate(ui, ht

我想知道如何使用jquery重新呈现dom元素。 我想按ID捕获一个表,并使用jquery重新呈现该表

此表是动态输入的。由于我是在加载html文件后添加表的,所以头部的Js文件不会响应我在加载html页面后添加的表。这是通过编辑器完成的

因此,我需要使用jquery重新呈现表。我使用Jquery和Jquery mobile作为我的框架

*对不起,我好像走错了路。我实际上想做的是使用jquery mobile重新呈现dom元素

    function insertTemplate(ui, html) {
    var el, n, dom = editor.dom, sel = editor.selection.getContent();

    each(editor.getParam('template_replace_values'), function(v, k) {
        if (typeof(v) != 'function') {
            html = html.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v);
        }

    });

    el = dom.create('div', null, html);

    // Find template element within div
    n = dom.select('.mceTmpl', el);
    if (n && n.length > 0) {
        el = dom.create('div', null);
        el.appendChild(n[0].cloneNode(true));
    }

    function hasClass(n, c) {
        return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
    }

    each(dom.select('*', el), function(n) {
        // Replace cdate
        if (hasClass(n, editor.getParam('template_cdate_classes', 'cdate').replace(/\s+/g, '|'))) {
            n.innerHTML = getDateTime(editor.getParam("template_cdate_format", editor.getLang("template.cdate_format")));
        }

        // Replace mdate
        if (hasClass(n, editor.getParam('template_mdate_classes', 'mdate').replace(/\s+/g, '|'))) {
            n.innerHTML = getDateTime(editor.getParam("template_mdate_format", editor.getLang("template.mdate_format")));
        }

        // Replace selection
        if (hasClass(n, editor.getParam('template_selected_content_classes', 'selcontent').replace(/\s+/g, '|'))) {
            n.innerHTML = sel;
        }
    });

    replaceVals(el);

    editor.execCommand('mceInsertContent', false, el.innerHTML);
    editor.addVisual();
    /*$('#testjqtable').trigger("create");*/
  //$("#testjqtable").table("refresh");

   // $("#lsEditorArea_ifr").load('<table data-role="table" id="movie-table" data-mode="reflow" class="ui-responsive table-stroke jqm-table"><thead><tr><th data-priority="1">Rank</th><th data-priority="persist">Movie Title</th><th data-priority="2">Year</th><th data-priority="3"><abbr title="Rotten Tomato Rating">Rating</abbr></th><th data-priority="4">Reviews</th></tr></thead><tbody><tr><th>1</th><td><a href="http://en.wikipedia.org/wiki/Citizen_Kane" data-rel="external">Citizen Kane</a></td><td>1941</td><td>100%</td><td>74</td></tr><tr><th>2</th><td><a href="http://en.wikipedia.org/wiki/Casablanca_(film)" data-rel="external">Casablanca</a></td><td>1942</td><td>97%</td><td>64</td></tr><tr><th>3</th><td><a href="http://en.wikipedia.org/wiki/The_Godfather" data-rel="external">The Godfather</a></td><td>1972</td><td>97%</td><td>87</td></tr><tr><th>4</th><td><a href="http://en.wikipedia.org/wiki/Gone_with_the_Wind_(film)" data-rel="external">Gone with the Wind</a></td><td>1939</td><td>96%</td><td>87</td></tr><tr><th>5</th><td><a href="http://en.wikipedia.org/wiki/Lawrence_of_Arabia_(film)" data-rel="external">Lawrence of Arabia</a></td><td>1962</td><td>94%</td><td>87</td></tr></tbody></table>');

}
函数插入模板(ui、html){
var el,n,dom=editor.dom,sel=editor.selection.getContent();
每个(editor.getParam('template_replace_values')、函数(v,k){
if(类型(v)!=‘功能’){
html=html.replace(新的RegExp('\\{\\$'+k+'\\}',g'),v);
}
});
el=dom.create('div',null,html);
//在div中查找模板元素
n=dom.select('.mceTmpl',el);
如果(n&&n.length>0){
el=dom.create('div',null);
el.appendChild(n[0].cloneNode(true));
}
函数类(n,c){
返回新的RegExp('\\b'+c+'\\b',g').test(n.className);
}
每个(dom.select('*',el),函数(n){
//取代cdate
if(hasClass(n,editor.getParam('template_cdate_classes','cdate')。replace(/\s+/g','124;')){
n、 innerHTML=getDateTime(editor.getParam(“template\u cdate\u格式”,editor.getLang(“template.cdate\u格式”));
}
//替换mdate
if(hasClass(n,editor.getParam('template_mdate_classes','mdate')。replace(/\s+/g','124;')){
n、 innerHTML=getDateTime(editor.getParam(“template\mdate\u格式”,editor.getLang(“template.mdate\u格式”));
}
//替换选择
if(hasClass(n,editor.getParam('template_selected_content_classes','selcontent')。replace(/\s+/g','124;')){
n、 innerHTML=sel;
}
});
替换值(el);
execCommand('mceInsertContent',false,el.innerHTML);
editor.addVisual();
/*$('testjqtable').trigger(“create”)*/
//$(“#testjqtable”).table(“刷新”);
//美元(“#lsEditorArea_ifr”).load('RankMovie TitleYear1941100%742194297%643197297%874193996%875196294%87');
}

为您的div尝试此方法,在ajax调用后添加

$('#yourDiv').trigger("create");
$('ul#listID').listview('refresh');
或者,对于listview,在ajax调用后添加插件

$('#yourDiv').trigger("create");
$('ul#listID').listview('refresh');

在大多数现代浏览器中执行动画会导致布局刷新,因此请隐藏它,然后显示它。向我们展示您拥有的内容,以便我们可以帮助修复代码。我在这里添加了代码,顺便说一句,我尝试了注释方法,第二种方法出现了未捕获类型错误,根据第一种情况,没有错误,但不起作用。