Reputation: 25
I want to call event when I press Enter Key or Dubble click.
I write this code for pressing Enter Key, But I don't know How can insert condition for dubble click.
onClickNode: function (node) {
$(document).keyup(function (e) {
if (e.which == 13) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: { id: node.data.id,name:node.data.name},
success: function (data) {
if (data.Success) {
// do something
}
//do something
});
},
});
}
});
}
Can you change this code with enter or dubble click press?
Upvotes: 0
Views: 1180
Reputation: 2308
$(document).on("keyup", function (e) {
if (e.which == 13) {
commonMethod(node);
}
});
$(document).on("dblclick", function (e) {
commonMethod(node);
});
function commomMethod(node) {
$.ajax({
url: '@Url.Action("EditNode", "Admin")',
type: 'POST',
data: {
id: node.data.id,
name: node.data.name
},
success: function (data) {
if (data.Success) {
// do something
}
//do something
}
});
}
Upvotes: 1