I have an autocomplete textbox that cannot fire the key down event.
Here is the code for the auto complete box
<script type="text/javascript">
$(document).ready(function () {
$("#TransFinishedPartNumber").autocomplete({
source: function (request, response) {
// define a function to call your Action
$.ajax({
url: '@Url.Action("partLookUp", "Transaction")',
// term will be the param used by your action method
data: { term: request.term },
success: function (data) {
response($.map(data, function (item) {
return { label: item.pt_part + " " + item.pt_desc1, value: item.pt_part };
}))
$("#TransFinishedPartNumber").removeClass('acLoading');
},
error: function () {
$("#TransFinishedPartNumber").removeClass('acLoading');
}
})
},
minLength: 1, // require at least one character from the user
search: function () { $(this).addClass('acLoading'); },
});
});
Now here is the event javascript it will never fire... not live or bind or anything for that matter... but the crazy thing is the autocomplete box works...
<script type="text/javascript">
//Transaction Event handlers and ajax calls
$(document).ready(function () {
$("#TransFinishedPartNumber").bind("keydown",function (e) {
$("#TransFinishedPartNumber").addClass("ui-state-default");
});
$("#TransFinishedPartNumber").bind("keydown",function (e) {
$("#TransFinishedPartNumber").removeClass("ui-state-default");
});
});
I tried this way also
<script type="text/javascript">
//Transaction Event handlers and ajax calls
$(document).ready(function () {
$("#TransFinishedPartNumber").keydown(function (e) {
$("#TransFinishedPartNumber").addClass("ui-state-default");
});
$("#TransFinishedPartNumber").keydown(function (e) {
$("#TransFinishedPartNumber").removeClass("ui-state-default");
});
});
I changed to this script to be absolutely sure
<script type="text/javascript">
//Transaction Event handlers and ajax calls
$(document).ready(function () {
$("#TransFinishedPartNumber").keydown(function (e) {
alert(e.which);
});
});