【发布时间】:2010-07-26 16:37:34
【问题描述】:
我想在运行与按钮关联的函数之前单击对话框中的按钮并更改消息区域上的文本,或者只是将文本更改为函数的一部分。
【问题讨论】:
标签: jquery user-interface dialog
我想在运行与按钮关联的函数之前单击对话框中的按钮并更改消息区域上的文本,或者只是将文本更改为函数的一部分。
【问题讨论】:
标签: jquery user-interface dialog
您可以像这样使用 .onclick 事件...
<div id="targetSelector">Click Me</div>
<div id="messageAreaSelector"></div>
//jquery code to attach click to targetSelector
$('#targetSelector').click(function() {
//code to update message area
$('#messageAreaSlector').html("Text to tell user");
//call to function you want to perform
CallSelfDefinedFunction(arguments);
});
【讨论】:
This is the default dialog... 等。然后您使用 $('idYouJustAppliedToThePTag' 更改文本).html('你想说什么');所以我认为克里斯是正确的答案,对吧?如果您无法访问段落标签的代码,可以这么说,您可以使用 jQuery 选择器来选择嵌入在对话框 div 中的标签。还是我错过了什么?
只需在对话框中放置一个文本区域,它将是可编辑的。如果你想切换是否可以编辑,只需添加一个按钮。
(function ($) {
var $dialog = $('<div></div>')
.html('<textarea id="myContent" rows=7 cols=25>Edit me</textarea>')
.dialog({
autoOpen: false,
title: 'editable dialog',
buttons: {
"Edit": function () { $("#myContent").attr("disabled", !$("#myContent").attr("disabled")); }
},
height: "auto",
width: "auto"
});
$('.dlog').click(function () {
$dialog.dialog('open');
return false;
});
})(jQuery);
【讨论】:
您可以将函数绑定到关闭事件 - http://jqueryui.com/demos/dialog/#event-close。我打赌你可以在里面修改你的文字。
【讨论】: