传递要在JQuery UI对话框中使用的HTML值?

时间:2022-01-28 17:06:54

I have the following scripts:

我有以下脚本:

 $(function (movie) {
        $("#dialog").dialog({
            autoOpen: false,
            show: {
                effect: "blind",
                duration: 500
            },
            hide: {
                effect: "explode",
                duration: 500
            }
        });
        $("td#dialog_link").click(function (e) {     

            $('#dialog').dialog('open');
            return false;
        });

And the following div to display the message:

和下面的div显示消息:

<div id="dialog" title="R">
<p>The value in the table is </p>
</div>

I just can't seem to find a way to pass in the value from the thing i'm clicking.

我似乎找不到从我点击的东西中传递值的方法。

It's set up so when I click an element in a table, it shows the dialog, but I want it to also display the value from what i'm clicking on in the dialog at the end or middle of the message.

当我点击表格中的一个元素时,它会显示对话框,但是我也想让它显示我在消息结尾或中间的对话框中点击的值。

Please help, I can't find it.

请帮忙,我找不到。

1 个解决方案

#1


3  

You can modify your dialog text before the modal opens. Something like this:

您可以在模式打开之前修改对话框文本。是这样的:

    $("td#dialog_link").click(function (e) {     
        $('#dialog').html('<p>The value in the table is '+$(this).text()+'</p>');
        $('#dialog').dialog('open');
        return false;
    });

Another option if you change your html a bit.

另一个选项,如果你稍微改变你的html。

    <div id="dialog" title="R">
      <p>The value in the table is <span id="tableVal"></span></p>
    </div>

     $("td#dialog_link").click(function (e) { 
        $('#tableVal').text($(this).text());    
        $('#dialog').dialog('open');
        return false;
    });

Example:

例子:

http://jsfiddle.net/QtBb8/

http://jsfiddle.net/QtBb8/

#1


3  

You can modify your dialog text before the modal opens. Something like this:

您可以在模式打开之前修改对话框文本。是这样的:

    $("td#dialog_link").click(function (e) {     
        $('#dialog').html('<p>The value in the table is '+$(this).text()+'</p>');
        $('#dialog').dialog('open');
        return false;
    });

Another option if you change your html a bit.

另一个选项,如果你稍微改变你的html。

    <div id="dialog" title="R">
      <p>The value in the table is <span id="tableVal"></span></p>
    </div>

     $("td#dialog_link").click(function (e) { 
        $('#tableVal').text($(this).text());    
        $('#dialog').dialog('open');
        return false;
    });

Example:

例子:

http://jsfiddle.net/QtBb8/

http://jsfiddle.net/QtBb8/