如何更改每行 jdialog 框消息中的文本? 正如您所看到的,在“订单详细信息”列的每一行中都有一个“显示”按钮。 我希望每一行都有不同的文本。 我尝试更改名称值,并将按钮的代码放入每个 td 元素中,但它仍然不起作用。
文中具体代码:
<div id="dialog-form" title="Order Details">
<p class="validateTips">Spicy Sandwitch</p>
<p class="validateTips">More</p>
<form>
<fieldset>
<label for="name">More Comments</label>
<p class="validateTips">Sandwitch only lettuce</p>
<!-- Allow form submission with keyboard without duplicating the dialog button -->
<input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
</fieldset>
</form>
</div>
<div id="users-contain" class="ui-widget"
完整代码here
最佳答案
为了使对话框的内容从一条记录变为另一条记录
您没有解释如何加载自定义内容?但我将指导您如何自定义每条记录的对话框内容。
第一:创建一个名为 openDialog() 的 JS 方法,该方法可以将对话框的上下文作为参数,也可以只接受记录 ID 并通过 AJAX 或其他方式加载内容
function openDialog(content="", record_id=0)
{
if(content.length > 0) // if you're passing content as a paramter
dialog.html(content);
if(record_id!=0) // if you're passing the record ID as a paramter
{
// load content via ajax or something
dialog.html("loaded content via AJAX for user number "+record_id);
}
dialog.dialog("open");
}
然后在您拥有的每个“显示”按钮中调用此方法
<button id="create-user-1" onclick="openDialog('Hello User #1');">New Show</button>
<button id="create-user-2" onclick="openDialog('',2);">New Show</button>
更新实际上您的完整代码有点困惑,但根据您的要求,我尝试将我的解决方案应用于您的 fiddle 代码,这是我的工作示例 https://jsfiddle.net/doaa_magdy_55/qtvw75z6/20/#&togetherjs=jSCLnBoUen
关于javascript - 每行不同的文本 Jquery Modal/Dialog 表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40890574/