Setting onblur, onkeyup and onkeydown for @Html.Kendo().TextBoxFor using HtmlAttributes
-
Hi all friends, I have a textbox like below, I want call jquery function on its onblur or onkeyup or onfocus etc. @Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" }) when I set it as $("#idTxtForCodeLookupCode").on('input', function () { debugger; SetLookupTableValue(); }); function SetLookupTableValue() { $("#txtLookupTableId").val($("#drpLookup").data("kendoDropDownList").value()); $("#txtLookupTableId").val(); } The SetLookupTableValue() function is not being called. I don't know the reason, maybe because TextBox is in Popup and the functions are in the main page. But I want to try it it works it I can set this onblur event or keyup or even onfocus events using HtmlAttributes, it might work. Can anybody please help me how to set those events using HtmlAttributes property. Any help would be very helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
-
Hi all friends, I have a textbox like below, I want call jquery function on its onblur or onkeyup or onfocus etc. @Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" }) when I set it as $("#idTxtForCodeLookupCode").on('input', function () { debugger; SetLookupTableValue(); }); function SetLookupTableValue() { $("#txtLookupTableId").val($("#drpLookup").data("kendoDropDownList").value()); $("#txtLookupTableId").val(); } The SetLookupTableValue() function is not being called. I don't know the reason, maybe because TextBox is in Popup and the functions are in the main page. But I want to try it it works it I can set this onblur event or keyup or even onfocus events using HtmlAttributes, it might work. Can anybody please help me how to set those events using HtmlAttributes property. Any help would be very helpful, thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."
Depends on the version of JQuery your using. The call changes as versions are updated. Technically, JQuery can select an element anywhere on the page or in the DOM, even if it's hidden. Best thing to do is test first. just have the function write an alert to see if it works first, then write your code to do it's thing.
$("#idTxtForCodeLookupCode").on('blur', function ()
$("#idTxtForCodeLookupCode").blur(function() {
focus, blur, keyup is very tricky and requires more code to listen to certain keys. I'm going to a seminar, the post JQuery world, in which basically JQuery is no longer needed with modern JavaScript and TypeScript being available now. Something for us to think about.
If it ain't broke don't fix it Discover my world at jkirkerx.com
-
Depends on the version of JQuery your using. The call changes as versions are updated. Technically, JQuery can select an element anywhere on the page or in the DOM, even if it's hidden. Best thing to do is test first. just have the function write an alert to see if it works first, then write your code to do it's thing.
$("#idTxtForCodeLookupCode").on('blur', function ()
$("#idTxtForCodeLookupCode").blur(function() {
focus, blur, keyup is very tricky and requires more code to listen to certain keys. I'm going to a seminar, the post JQuery world, in which basically JQuery is no longer needed with modern JavaScript and TypeScript being available now. Something for us to think about.
If it ain't broke don't fix it Discover my world at jkirkerx.com
The meetup was pretty cool. Technically we don't need JQuery anymore for modern browsers that support HTML5, because modern JavaScript is now part of the browser. You save a 2 meg download on pages that use JQuery. There are many small npm libraries like animate.css that are around 64K in size that can do animation for you and Ajax is built in now.
If it ain't broke don't fix it Discover my world at jkirkerx.com