[英]Pass button value to Url.Action in a modal
How can I go about passing this value on a button(the button starts the js onclick): 如何在按钮上传递此值(按钮启动js onclick):
<button class="launch" value= @item.Id role="button" name="dId">do it</button>
to a $(this).load("@Url.Action("myPartial", new { id = 1 })");
到$(this).load("@Url.Action("myPartial", new { id = 1 })");
I am looking to replace the 1
with the @item.Id
value from the button. 我希望用按钮替换@item.Id
值1
。 Thanks. 谢谢。
Here is the script: 这是脚本:
<script>
$(function () {
$("modal").dialog({
autoOpen: false,
height: 600,
width: 700,
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("myPartial", new { id = 1 })");
},
buttons:{
"Close": function () {
$(this).dialog("close");
}
}
});
$(".launch").click(function () {
$("#modal").dialog("open");
})
});
</script>
Add an id to your button: 在按钮中添加ID:
Html: HTML:
<button class="launch" value= "@item.Id" id="button" role="button" name="dId">do it</button>
JS: JS:
var button=document.getElementById("button");
$(this).load("@Url.Action("myPartial", new { id ="button.value" })");
Was this what you were looking for? 这是你在找什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.