tags:

views:

16

answers:

1
    var dlg = $("#dialog").dialog({
      autoOpen: false,
      modal: true,
      buttons: {
        'Update': function() {
          alert(clientCode);
        },
        Cancel: function() {
          $(this).dialog('close');
        }
      }
    });

    $(".edit").click(function() {
      myval = $(this).parent().children('td:nth-child(1)').text();
      dlg.dialog('open');
      return false;
    });

How do I take "myval" and have it as the title of the dialog? I've tried passing it as an argument when doing dlg.dialog('open', myval) and no luck. I've also tried passing it as a parameter but with no luck either. I'm probably doing things in the wrong way, however.

A: 

create the dialog in the click-event and use this to set title:

something like this:

$(".edit").click(function() {
  myval = $(this).parent().children('td:nth-child(1)').text();

  var dlg = $("#dialog").dialog({
  autoOpen: false,
  title: myval,
  modal: true,
  buttons: {
      'Update': function() {
        alert(clientCode);
      },
      Cancel: function() {
        $(this).dialog('close');
      }
    }
  });

  dlg.dialog('open');
  return false;
});
Natrium