- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我知道有人问过这个问题,我已经尝试过这些解决方案,但无法解决这个问题..
How clear bootstrap modal on hide
How to clear all input fields in bootstrap modal when clicking data-dismiss button?
但是这些解决方案并没有解决我的问题,
我想清除模态弹出窗口隐藏的输入字段
这是我的观点
@model IEnumerable<Recon.Models.BRANCH_CONTACT_INFO>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h4><b>Contact Person Detail</b></h4>
@*<p>
@Html.ActionLink("Create New", "Create")
</p>*@
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
<table class="table table-striped table-hover table-bordered">
<tr class="info">
<th>
@Html.Label("Manager Name")
</th>
<th>
@Html.Label("Designation")
</th>
<th>
@Html.Label("Email 1")
</th>
<th>
@Html.Label("Email 2")
</th>
@*<th>
@Html.Label("Branch Name")
</th>*@
<th>
@Html.ActionLink("Add", "Create_Branch_Contact_info", new { id = Session["Branchid"] }, new { @class = "btn default btn-xs green-stripe", data_toggle = "modal", data_target = "#myModal" })
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.MANAGER_NAME)
</td>
<td>
@Html.DisplayFor(modelItem => item.DESIGNATION.DESIGNATION1)
</td>
<td>
@Html.DisplayFor(modelItem => item.EMAIL1)
</td>
<td>
@Html.DisplayFor(modelItem => item.EMAIL2)
</td>
@*<td>
@Html.DisplayFor(modelItem => item.BRANCH.BRANCH_DESC)
</td>*@
<td>
@Html.ActionLink("Update", "Edit_Branch_Contact_info", new { id = item.BRANCH_CONT_ID }, new { @class = "btn default btn-xs blue-stripe" })
@*@Html.ActionLink("Details", "Details", new { id = item.BRANCH_CONT_ID }) |*@
@Html.ActionLink("Remove", "Delete","contact", new { id = item.BRANCH_CONT_ID }, new { @class = "btn default btn-xs red-stripe" })
</td>
</tr>
}
</table>
@section script{
<script>
debugger;
function myFunction() {
debugger;
//$('.modal').remove();
document.getElementById("demo").innerHTML = "Hello World";
}
$('#myModal').on('hidden', function (e) {
debugger;
$(this)
.find("input,textarea,select")
.val('')
.end()
.find("input[type=checkbox], input[type=radio]")
.prop("checked", "")
.end();
})
$('[data-dismiss=modal]').on('click', function (e) {
debugger;
var $t = $(this),
target = $t[0].href || $t.data("target") || $t.parents('.modal') || [];
$(target)
.find("input,textarea,select")
.val('')
.end()
.find("input[type=checkbox], input[type=radio]")
.prop("checked", "")
.end();
})
$('body').on('hidden.modal', '.modal', function () {
debugger;
$(this).removeData('.modal');
});
</script>
}
正如您在我的 View 中看到的,这就是我在模态弹出窗口中调用其他 View 的方式
@Html.ActionLink("Add", "Create_Branch_Contact_info", new { id = Session["Branchid"] }, new { @class = "btn default btn-xs green-stripe", data_toggle = "modal", data_target = "#myModal" })
还有我的模态所在的另一个 View
@model Recon.Models.BRANCH_CONTACT_INFO
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@{
Layout = "";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
@*<h4 class="modal-title" id="myModalLabel">Add Contact</h4>*@
</div>
<div class="modal-body" id="modal123">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
Add Contact to Branch
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form id="form" action="javascript:;" class="form-horizontal">
<div class="form-body">
<div class="portlet-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3">Manager Name</label>
<div class="col-md-9">
@Html.TextBoxFor(model => model.MANAGER_NAME, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.MANAGER_NAME)
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3">Designation</label>
<div class="col-md-9">
@Html.DropDownList("DESIGNATION_ID", null, "Select Designation", new { @class = "form-control" })
@Html.ValidationMessage("DESIGNATION_ID")
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3">Email 1</label>
<div class="col-md-9">
@Html.TextBoxFor(model => model.EMAIL1, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.EMAIL1)
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3">Email 2</label>
<div class="col-md-9">
@Html.TextBoxFor(model => model.EMAIL2, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.EMAIL2)
</div>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="control-label col-md-3">Branch Name</label>
<div class="col-md-9">
@Html.TextBox("BRANCH_NAME", (string)ViewBag.BranchName, new { @class = "form-control", @readonly = "readonly" })
</div>
</div>
</div>
</div>
@Html.TextBox("BRANCH_ID", (Int16)ViewBag.BRANCH_ID, new { style = "display:none;" })
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-offset-3 col-md-9">
@*<input type="submit" value="Save" class=" btn default btn-xs blue-stripe " id="btnsave" />*@
<button type="button" class="btn btn-default" onclick="myFunction()" data-dismiss="modal">Cancel</button>
<input type="submit" value="Save" class="btn blue" />
@*@Html.ActionLink("Back to List", "Index", new { Trtype = @Session["Trtype"], Product_ID = @Session["Product_ID"] }, new { @class = "btn red" })*@
</div>
</div>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</form>
<!-- END FORM-->
<p id="demo"></p>
</div>
</div>
</div>
@*<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<input type="submit" value="Delete" id="btnsave" class="btn btn-primary"/>
</div>*@
}
我已经使用 jquery 尝试过这些解决方案,但没有任何效果,
我尝试的第一个解决方案是在“取消”按钮上创建一个 onclick 事件并调用此函数
function myFunction() {
debugger;
$('.modal').remove();
}
但它实际上删除了我的整个模式弹出窗口,我无法再次打开我的模式
第二次我尝试了这个
$('#myModal').on('hidden', function (e) {
debugger;
$(this)
.find("input,textarea,select")
.val('')
.end()
.find("input[type=checkbox], input[type=radio]")
.prop("checked", "")
.end();
})
还有这个
$('[data-dismiss=modal]').on('click', function (e) {
debugger;
var $t = $(this),
target = $t[0].href || $t.data("target") || $t.parents('.modal') || [];
$(target)
.find("input,textarea,select")
.val('')
.end()
.find("input[type=checkbox], input[type=radio]")
.prop("checked", "")
.end();
})
还有这个:
$('body').on('hidden.modal', '.modal', function () {
debugger;
$(this).removeData('.modal');
});
但是它们不起作用
不知道我在做什么,错误请帮助!任何建议将不胜感激
最佳答案
****在这里你可以这样做......****
方法1:
$('#myModal').on('hidden.bs.modal', function (e) {
var modal = $(this);//The modal which is opened
modal.find("input").val("");//Clear all the input fileds inside that modal.
});
方法 2:
如果这仍然不起作用,因为您可能使用部分页面调用模式的内部内容,那么您可以尝试在打开时清除模式内的所有字段。
$('#myModal').on('show.bs.modal', function (e) {
var modal = $(this);//The modal which is opened
modal.find("input").val("");//Clear all the input fileds inside that modal.
});
关于javascript - 隐藏模态后,模态中文本框的值不会被清除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40036673/
是否有更快的算法来计算 (n! modulo m)。在每个乘法步骤都比减少更快。并且有没有比左右二元法更快的算法来计算 (a^p modulo m)。 这是我的代码:n!模数m ans=1 for(i
我有非常简单的代码循环遍历数组中的元素并检查是否index % 2 == 0。如果是这样,它应该改变颜色。 var e = document.getElementById("list").childN
让我简短一点。我正在计算 alert((Math.pow(7,35))%71) 但它给了我 61,而结果必须是 70。怎么了? 最佳答案 正如其他人之前提到的关于使用 Math.pow(7,35) 的
我试图弄清楚如何在汇编中计算模 10,所以我在 gcc 中编译了以下 c 代码,看看它想出了什么。 unsigned int i=999; unsigned int j=i%10; 令我惊讶的是我得到
例如使用以下输入: int num = -100 int divisor = 10 => -100 mod 10 = 0 (Edge-case: negative numbers as inpu
这个问题在这里已经有了答案: Random float number generation (14 个答案) 关闭 9 年前。 在 C++ 中,我希望得到一个随机 float 。据我所知,典型的随机
我试图找到潜在阶乘素数的除数(n!+-1 形式的数),因为我最近购买了 Skylake-X 工作站,我认为我可以使用 AVX512 指令提高一些速度。 算法简单,主要步骤是对同一个除数重复取模。主要是
我有一个保存角度(以度为单位)的变量,该角度可以是正值也可以是负值。我现在需要确保该数字仅在 0 到 360 之间。该数字是 double 。 执行此操作的好算法是什么?简单地执行角度 % 360 是
我有一个 UInt8 数组,我想计算 CheckSum8 模 256。如果字节总和小于 255,checkSum 函数返回正确的值。 例如 let bytes1 : [UInt8] = [1, 0xa
使用海湾合作委员会: printf("%i \n", -1 % (int)4); printf("%u \n", -1 % (unsigned int)4); 输出: -1 3 我可以跨平台依赖这种行
我无法理解代码中几行的含义。我最近开始学习 C++,并阅读了 Bjarne Stroustrup 的“编程:使用 C++ 的原理和实践”。第四章有个问题让我很困惑,所以我在网上搜索了一个解决方案以供引
我试图解决一个涉及大阶乘模质数的问题,并在另一个人的解决方案中发现了以下算法: long long factMod (long long n, long long p) { long long
我正在尝试计算 𝐹𝑛 模 𝑚,其中 𝑛 可能非常大:高达 10^18,𝐹𝑛 是第 n 个斐波那契数这是我的代码,它适用于小数字,但对于大数字,它会抛出 OutOfMemoryError 或
我有两个以 16 为模的循环整数,因此它们的值介于 0 和 15 之间。 我需要比较两个数字以确定 n_1 是否大于 n_0 n_1 > n_0 很明显,这个没有准确定义,所以我定义n_1如果小于前面
我一直在尝试使用 Java 处理一些更大的值,但遇到了一些我不理解的问题。出于某种原因,Java 似乎喜欢给我垃圾数据(尽管,我更可能告诉它给我垃圾数据) 这是一个片段,为清楚起见进行了编辑:
好吧,我今天做了一个小函数,它应该会生成一个随机字符串。 std::string randString(size_t length) { std::string randStr; fo
Ruby 的负数取模规则不明确。在 IRB 中: -7 % 3 == 2 应该是1!为什么? 最佳答案 因为 -7/3 在 Ruby 的整数除法语义下是 -3。 3*-3 是 -9,所以会留下 2
这个问题在这里已经有了答案: Calculating pow(a,b) mod n (14 个答案) 关闭 6 年前。 在 Javascript 中是否有获取大数模数的技巧。我用 modulo(7,
此代码使用公式 (a^x) % 101 检查值 a 是否唯一映射到值 1 到 100 local function f(a) found = {} bijective = true
在《Core Java Volume1》一书中有一条警告: CAUTION: The right-hand side argument of the shift operators is reduce
我是一名优秀的程序员,十分优秀!