Javascript 初始化后如何更改jQuery对话框html内容?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3780695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 06:07:42  来源:igfitidea点击:

How to change jQuery dialog html content after init?

javascriptjqueryjquery-ui

提问by Erez

I have a working dialog, and i want to change the content during the flow of the app, I mean to change the .html() property of the dialog...

我有一个工作对话框,我想在应用程序的流程中更改内容,我的意思是更改对话框的 .html() 属性...

I thought it was easy to do but i can't seem to do:

我认为这很容易做到,但我似乎做不到:

$dialog.dialog().html(SOME CONTENT);

$dialog.dialog().html(一些内容);

How do I do that after I already have the dialog running?

在我已经运行了对话框之后,我该怎么做?

My init code is:

我的初始化代码是:

var $dialog = $('<div></div>')
    .html(SplitTable)
    .dialog({
        autoOpen: false,
        height: 500,
        width: 600,
        title: '????? ?????'});

    $dialog.dialog('open');

where is the ID in that? this is the what i understood i should do from the examples, didn't see any Id property...

那个ID在哪里?这是我从示例中理解的我应该做的事情,没有看到任何 Id 属性...

p.s. splitTableis the content that i need to change during to program to updatTable...

ps splitTable是我在编程到updatTable期间需要更改的内容...

10x

10倍

回答by Nick Craver

Make sure that the $dialogvariable is in scope where you're wanting to change the content, then just a .html()call will work, like this:

确保$dialog变量在您要更改内容的范围内,然后只需.html()调用即可,如下所示:

$dialog.html(updatTable);

You can see it working here.

你可以看到它在这里工作

回答by trrrrrrm

$('#dialog ID').html('SOME CONTENT');