3

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 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 Answer 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.

    <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/

Sign up to request clarification or add additional context in comments.

3 Comments

How would I pass that to the <div> i'm using to store my html response though? I'd rather do that then inline the .html(...).
Oh our trying to pass in the value from the thing your clicking.. Check my update.
Absolutely brilliant. Thank you so much for your help, it's perfect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.