[英]MVC onfocusout event not firing
Im getting confused about the onfocusout event in my mvc view. 我对我的mvc视图中的onfocusout事件感到困惑。
<div class="editor-field" id="supplieridentificationID" >
@Html.EditorFor(m => m.SupplierIdentification)
</div>
<div id="suppliername" class="editor-label" />
And my javascript code: 和我的JavaScript代码:
$('#supplieridentificationID').onfocusout(function () { alert("ajax here!" })
I cant get this to work, actually im trying to send the SupplierIdentification to my controller and get the Json with the SupplierName and put on "suppliername" label. 我无法正常工作,实际上我试图将SupplierIdentification发送到我的控制器,并获得带有SupplierName的Json并贴上“ suppliername”标签。 All using onfocusout function with the ajax. 都使用带有ajax的onfocusout函数。
Any sugestions? 有任何建议吗?
EDIT: 编辑:
I tried other code, and still not getting nothing: 我尝试了其他代码,但仍然一无所获:
<div>
<fieldset>
<legend>Novo Documento</legend>
<div class="editor-field" id="ident">
@Html.EditorFor(m => m.SupplierIdentification)
</div>
</fieldset>
</div>
And script: 和脚本:
<script type="text/javascript">
$(document).ready(function() {
$('#ident').focusin(function () { alert("focusin"); });
});
使用focusout
而不是onfocusout
$('#SupplierIdentification').focusout(function() { alert("ajax here!" });
try adding an id to control so you can reference it in Jquery. 尝试添加ID进行控制,以便您可以在Jquery中引用它。
@Html.EditorFor(m => m.SupplierIdentification, new { @id = "id"})
$(document).ready(function() {
$('#id').blur(function () {
alert("focusin");
});
});
blur function happens when element loses focus 元素失去焦点时会发生模糊功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.