jquery对话框 - 哪个按钮打开对话框? [英] jquery dialog - which button opened the dialog?

查看:154
本文介绍了jquery对话框 - 哪个按钮打开对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的示例中,如何使用事件和ui对象来检测哪个链接打开对话框?似乎不能得到$(event.target).attr(title);正常工作,我无法找到通过的ui对象上的文档。谢谢!

In the example below, how can you use the event and ui objects to detect which link opened the dialog? Can't seem to get $(event.target).attr("title"); to work properly, and I'm having trouble finding documentation on the 'ui object that is passed. Thanks!

$("#dialog_support_option_form").dialog({
   link_title = $(event.target).attr("title");
   alert(link_title);
});


$("a").live("click", function() {
    btn_rel = $(this).attr("rel");
    $(btn_rel).dialog("open");
});

<a class="btn pencil" rel="#dialog_support_option_form" title="Edit Support Option">Edit</button>


推荐答案

您需要在单击事件打开它,然后可以使用它,并在对话框中设置一些东西,提醒它...无论你想要做的这样的值,如下所示:

You need to do that detection in the click event that opens it, you can then use it and set something in the dialog, alert it...whatever you're looking to do with the value, like this:

$("a").live("click", function() {
  var btn_rel = $(this).attr("rel");
  $(btn_rel).dialog("open");
  var title = $(this).attr("title");
  //alert(title);
  //or:
  //$("#dialog_support_option_form .something").text(title);
  //whatever you want to do with it :)
});

这篇关于jquery对话框 - 哪个按钮打开对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆